wood burning stoves*
The moose likes Tomcat and the fly likes How to change tomcat server.xml programatically. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to change tomcat server.xml programatically." Watch "How to change tomcat server.xml programatically." New topic
Author

How to change tomcat server.xml programatically.

anushka vaze
Greenhorn

Joined: Apr 24, 2012
Posts: 4
Hi I want to change tomcat-server.xml of embedded tomcat in Virgo programatically. What are the possible options for that?
Is there a way/ API through which I can change the tomcat server.xml through coding?
We just need to know if there is a way for parsing + modification through the configurations APIs of Apache/tomcat (if there is any)
thanks!!

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Embedded Tomcat typically doesn't use tomcat-server.xml, because the embedded Tomcat is a JavaBean and it is configured using POJO properties on the Tomcat bean. Which is basically what tomcat-server.xml is for - it's a set of specifications for configuring the Tomcat startup.

So the answer to your question depends on how Virgo configures Tomcat. I've never heard of Virgo, myself, though.


Customer surveys are for companies who didn't pay proper attention to begin with.
anushka vaze
Greenhorn

Joined: Apr 24, 2012
Posts: 4
In general how can I get the control to change the connector attributes from tomcat server.xml like port timeout etc through API.
Are there any exposed API if I have the handle to read the server.xml.
My moto is to chnage the server.xml programatically which will allow me to call APIs like setPort() or setConnectionTimeout() etc which will change the setting for tomcat server. This can be static or dynamic in whichever way it is possible.
If it works for standalone tomcat , possibly it will work for Virgo Tomcat Server as well which is nothibg but the OSGi implementation of Equinox giving a support for tomcat through embedding it in Virgo.

Please let me know if there is a way to get the handle of the tomcat server or some of the configuration related classes of tomcat and which can be changed programatically.

Thanks!!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Server.xml is digested and processed when Tomcat starts up and ignored until the next startup, so changing it for the purpose of dynamically modifying Tomcat is futile - that's why you're not supposed to put Context elements in server.xml.

Once Tomcat is running, an embedded Tomcat is a JavaBean and you dynamically modify it using the bean methods. This, of course, supposes that you own the bean.

For external dynamic controls, there are several interfaces, including JMX, JSR-77, JSR-88 (and their successors), the Tomcat management webapps (if installed).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to change tomcat server.xml programatically.
 
Similar Threads
Getting servlet to work with TOMCAT4.1.18
setup context under Tomcat
tomcat 6 - how to define context root name diff than WAR file name
Query about 'Port' Number??
tomcat port