When is it useful to define context.xml in some other place than at /META-INF/context.xml inside the application files ?
When do you usually do it ? Is it frequently used ? I am not asking about theoretical possibilities, but how are they used in practical scenarios. Most common case I encounter is in /META-INF/context.xml inside the application files. Similary, do you ofter set explicitly CATALINA_BASE outside of CATALINA_HOME ? Most common scenario I see is deploying into TomcatInstallDir(CATALINA_HOME)/webapps. When should CATALINA_BASE be defined ? Is running each webapp on separate tomcat/jboss instead of running all in the same tomcat / jboss an antipattern ? In students handbooks and lectures it was said, that jars, memory, resources are shared in one tomcat/jboss which is so good. In practice we have memory leaks and need of restarts, conflicts between versions of jars and classloaders. And what are more problems running everything in one tomcat/jboss? What do you see more ofte, all webapps in one server or each in separate ? Regards Jakub piece of doc concerning context topic http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Defining_a_context *Defining a context* *It is NOT recommended to place <Context> elements directly in the server.xml file.* This is because it makes modifying the *Context*configuration more invasive since the main conf/server.xml file cannot be reloaded without restarting Tomcat. Individual *Context* elements may be explicitly defined: - In an individual file at /META-INF/context.xml inside the application files. Optionally (based on the Host's copyXML attribute) this may be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to application's base file name plus a ".xml" extension. - In individual files (with a ".xml" extension) in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory. The context path and version will be derived from the base name of the file (the file name less the .xml extension). This file will always take precedence over any context.xml file packaged in the web application's META-INF directory. - Inside a Host<http://tomcat.apache.org/tomcat-7.0-doc/config/host.html>element in the main conf/server.xml. Default *Context* elements may be defined that apply to multiple web applications. Configuration for an individual web application will override anything configured in one of these defaults. Any nested elements, e.g. <Resource> elements, that are defined in a default *Context* will be created once for each *Context* to which the default applies. They will *not * be shared between *Context* elements.