Changing the context root of your java web app

Problem: In Eclipse, I made a copy of an existing web app and tried to deploy on my local tomat. This failed as it had the same context root (e.g. http://localhost.8080/webapp1) as the existing project I copied from. To fix this, I changed the context root on the new project to something new. I did this by selecting project properties -> Web Project Settings -> Context Root. From here I was able to change the webapp context root to something else (e.g. http://localhost.8080/webapp2), which should allow both projects to be deployed in parallel. While this seemed to be all that was needed, I received the following error when trying to actually deploy the app.

context_error

Solution:
To resolve this issue, tomcat needs to be issued with the ‘clean’ command in order to pick up and activate the changes to the context root of deployed applications. To do this…
1) Stop tomcat.
2) right click on your server from within the servers window and select ‘clean’.
tomcat_clean
3) Click OK when asked to republish from scratch.
4) Click YES to when asked if you want to update the context root of the module you just changed.
5) The server should now automatically restart. You should now be able to successfully navigate to both applications as they are deployed on different context roots.

Leave a Reply

Your email address will not be published. Required fields are marked *