• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in Setting ContextPath

 
Greenhorn
Posts: 5
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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?
 
Saloon Keeper
Posts: 27876
197
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic