top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Tomcat: Modify content in META-INF/context.xml

+1 vote
572 views

I'm using Apache Tomcat 6.0.24 and I've deployed a web application that defines its resources into META-INF/context.xml , especially information about connection pool

Sometimes I''ve to edit that file to change some data , i.e, database's JDBC url

I've seen that restart web application is not enough to apply these changes , so I need to redeploy the web application ( I mean, unpack WAR file, modify it , repack it again, copy to deploy folder ...)

Question:
Do you know other way to modify META-INF/context.xml and apply the changes and don't have to redeploy the WAR file? Restart the web application is not a problem, but restart Tomcat is?

posted Dec 17, 2013 by Mandeep Sehgal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Without having any idea really of the precise mechanism behind database connections, I can  still imagine that with the possibility of pooled connections to said database(s), it may be difficult to detect such a change in the corresponding context.xml and apply them "on the fly". Even more so if such connections could be shared between different applications.
Thanks, but I didn't said that I neeed to apply changes "on the fly". Indeed, I said "Restart the web application is not a problem"

I only wan't to have to redeploy the web application to modify META-INF/context.xml and apply changes.

1 Answer

+1 vote

How do you feel about a Tomcat upgrade?

Automatic deployment has had a bit of an overhaul in Tomcat 8 and those changes have been back-ported to 7.0.x for the next release. The behavior in a number of edge cases is now clearly defined:
http://ci.apache.org/projects/tomcat/tomcat8/docs/config/automatic-deployment.html

In your case, you'd want to deploy as a WAR with unpackWARs set to true. Then, any time you edit the META-INF/context.xml in the unpacked directory the web application will be redeployed using the new context.xml

This might work with 6 but I can't remember (it is a long time since I looked at the 6.0.x automatic deployment code).

answer Dec 17, 2013 by Sanketi Garg
Similar Questions
+1 vote

I am using Tomcat version 7.0.40.

Whenever there is an entry to context.xml, the context.xml reloads and redeploys the webapps since it is configured that way and is required to be that way. When a user hits a URL at this point, the page will be blank since reloading is still underway. My concern is - is there a way to determine when the reload is complete? Also, is there a way to display a meaningful message when the user hits a page during reload?

+2 votes

I installed apache-tomcat-7.0.47 on debian and also installed and configured railo 4.1.1.009. I added the servlet for CFML and now i ended up with lots of WEB-INF directories in my tomcat directory and the subdirectories.

A find gives me the following output :

./lib/WEB-INF
./bin/WEB-INF
./work/WEB-INF
./logs/WEB-INF
./temp/WEB-INF
./conf/WEB-INF
./default/examples/WEB-INF
./default/WEB-INF
./default/manager/WEB-INF
./default/host-manager/WEB-INF
./default/ROOT/WEB-INF
./default/docs/appdev/sample/web/WEB-INF
./default/docs/WEB-INF
./webapps/WEB-INF
./webapps/ROOT/WEB-INF

The tomcat takes quite a while (350s) to start up and this is really starting to annoy me. So, whats this and what are some common settings to achieve a faster start up of the tomcat?

0 votes

I am just wondering whether somehow I can use web.xml to point to the Tomcat JDBC Realm that I am using. Are those two completely disjoint or I can link them together.

+1 vote

I want to access the JNDI Directory context in Tomcat8. I've used DirContextURLStreamHandler class which was in Tomcat 7. But now that has been removed.

Can someone tell me how can I access the JNDI Directory Context in Tomcat 8?

+1 vote

We have a context that includes an underscore and that is unfortunately causing problems w/ a load balancer and cookie paths. Our URLs resemble this:

https://example.com/the_context/login.jsp

Where we have deployed a war file named "the_context.war".

I'd like to somehow alias the context name so both of these urls would effectively be the same:

https://example.com/the_context/login.jsp
https://example.com/thecontext/login.jsp

Ideally this would be done w/o deploying the application twice. Is this possible in Tomcat 6 and/or 7 ?

...