1
votes

Seems I can't figure out how to deploy a web application to a path I want on tomcat 7. Here are the details:

  1. I have a war file called myapp.war which I want to be located under /home/user/myapp.war (not where tomcat is installed).
  2. I would like to have it deployed on tomcat under the path /api/1/

If I place myapp.war directly under the webapps directory of tomcat it will deploy, but under the path /myapp, which is not what I need. I'm also trying to avoid editing tomcat's server.xml file.

I understand there are ways to do it using context files, but anything I tried just didn't work, looks like I'm missing something. If someone could describe the precise configuration to have this working it will be most appreciated.

Thanks! Ariel

2

2 Answers

1
votes

This link has the explanation and how to do it. http://www3.ntu.edu.sg/home/ehchua/programming/howto/Tomcat_More.html

If you insist on using a webapp name that doesn't match the expected URL, then you must keep the webapp outside of the appBase directory, and create a conf/Catalina/[host]/[appName].xml file containing a element with a docBase attribute that points to the deployed location. Note that [appName] above is what you want to appear in the URL.

0
votes

I had a similar issue and I tried the following apparoach and it worked for me:
Rename war file to match the context path and replace "/" with "#". For example: api#1#myapp.war

If you are using the context.xml then also you will have to rename it to api#1#myapp.xml

I hope it works for you as well. If you find other solution please share.