Setting Context Path in Tomcat7 to change ROOT

1.6k views Asked by At

So, the inverse of this question has been asked before and answered here: How to set the context path of a web application in Tomcat 7.0. However, my application is deployed as "ROOT" and I need it to be available at "my-path" instead of deploying it at "my-path" and needing it available at "ROOT". I'm trying out Amazon's Elastic Beanstalk offering and a deployed war will always go to ROOT. I don't have any control over this and there is not .war file left behind. I tried to aforementioned topic to solve my problem, but it seems that pointing ROOT to another path doesn't work, while pointing another path to ROOT does work.

I will have to create an AMI so that auto scaling can take place without me touching new instances. The only thing I have been able to do to get this working was to create a symbolic link in the webapps folder that points "my-path" to "ROOT." I have no idea if there are significant repercussions of this setup and would like to hear if there are and what alternative there may be that makes use of Tomcat's settings instead or even another non-Tomcat solution.

Thanks!

Update: Once I created the AWS AMI with a symbolic link in the webapps folder and actually changed the AMI in Elastic Beanstalk, I found that my original solution will not work because Beanstalk wipes out the entire webapps directory.

1

There are 1 answers

1
Mark Thomas On

One way to do this would be to deploy the application as ROOT but configure it so all the resources are under the path /my-app in the ROOT web application.

For an existing application deployed as ROOT this would require:

  • Add a "my-app" directory to the root of the web application and move all your static resources from the root of the web application in to the "my-app" directory.
  • Add the path "/my-app" to the beginning of all the URL paths in your web.xml and/or annotations