I've a web application running in Tomcat 6.0.20. I do the deployment by creating a war file, copying it to webapps folder and starting the server.
My War file name is eligibility.war (I cannot change my war file name). If I deploy eligibility.war, my context path is /eligibility and my app can be accessed in the URI /eligibility/EligibilityService. This much is fine.
I need to expose my application in the URI /ws/CustomerManagement/eligibility/EligibilityService. For this I need to set my context path to /ws and configure my application (web.xml) to direct the URL pattern /CustomerManagement/* to my Servlet.
To set context path Tomcat documentation mentions different methods. I tried all and not getting a result.
1. Created a context.xml in META-INF folder (in WebContent) - The content of the context.xml is <Context path="/ws" reloadable="true" />
2. Packaged the war(eligibility.war), copied to webapps, started the server.
3. According to Tomcat documentation, Tomcat should copy the context.xml in the name ws.xml in conf/Catalina/localhost/.
Instead it copies the context.xml to conf/Catalina/localhost/ and names it eligibility.xml - Result: My context set to /eligibility instead of /ws
The second method I tried is to create a ws.xml in conf/Catalina/localhost/ with the content <Context path="/ws" docBase="C:/Programs/Tomcat/Webapps/eligibility.war" reloadable="true" />. This one fails saying that it cannot find the folder "ws" in webapps folder. However if I put the war somewhere else (E.g.: C:\) and give the docbase as "C:/eligibility.war". Unfortunately, I cannot put the war file anywhere else than webapps folder due to our process.
Tomcat recommends not to edit server.xml. I tried that too. It also gives error.
I prefer the 1st method if it could work.
Can anyone help?
I'm not aware that the WAR's META-INF/context.xml file was supposed to be copied from the WAR into CATALINA_BASE/conf/Catalina/localhost/, and I don't know why it should be necessary. However, if your context.xml file is being correctly found and processed, you will see a message that informs you what was done with it in the Tomcat log (catalina.out).
Your second alternative puzzles me, since I've been doing it for years with no problem. The only obvious thing I can suggest is that you be very careful to capitalize all the file and directory names properly, since while Windows doesn't care, Java does. But it's acting like C:/Programs/Tomcat/Webapps/eligibility.war is a directory and not a file.
One final caution: When redeploying a WAR file by dropping it into CATALINA_BASE/webapps, delete any directories with the same name you may find there, since they'll be exploded copies of the previous WAR file, and Tomcat will use those old, stale files instead of the newly-deployed WAR. It's not a bad idea to clean out your CATALINA_BASE/work directory either.
An IDE is no substitute for an Intelligent Developer.