How to change the default value of context.xml in Tomcat?

3.8k Views Asked by At

I am trying to use the crossContext feature in Tomcat so that I need to set <Context crossContext="true"> in the context.xml file located in mypath\apache-tomcat-7.0.41\conf folder.

However I find that every time I restart tomcat it will restore to its original value then I have to modify that again. I want to know if there is a way to avoid this so that I do not need to modify the context.xml file every time I restart Tomcat?

Thanks in advance!

<Context crossContext="true">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Manager pathname="" />
</Context>

above is the code I am using...

2

There are 2 best solutions below

0
On BEST ANSWER

According the the answer in this question [link] Tomcat context.xml files, is there a hiearchy? I figured out the way to solve this problem. Just create the context.xml file in the location mypath\apache-tomcat-7.0.41\conf\Catalina\localhost and add in <Context crossContext="true"> </Context> then you are done.

1
On

You need to undeploy your web application and then re-deploy it. Tomcat is re-using the context.xml file you provided on initial deployment, which you can find in CATALINA_BASE/conf/[engine]/[host]/[context].xml. The changes you are making to your own context.xml are probably being completely ignored.