Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Tomcat 7 do you need to copy context.xml into conf/Catalina/locahost for it to take effect

Just moved from Tomcat 6 to Tomcat 7 and noticed that when you deploy a webapp called widget the META-INF/context.xml no longer get copied to conf/Catalina/localhost/widget.xml.

What Im unclear about is whether it needs to be, will the settings in context.xml be used if left in META-INF or do they only have effect if moved to conf/Catalina/localhost/widget.xml

Im using a vanilla tomcat 7 installation

like image 352
Paul Taylor Avatar asked Sep 27 '12 20:09

Paul Taylor


2 Answers

See the documentation (my emphasis):

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.

The documentation for Host has this to say on copyXML:

Set to true if you want a context XML descriptor embedded inside the application (located at /META-INF/context.xml) to be copied to xmlBase when the application is deployed. On subsequent starts, the copied context XML descriptor will be used in preference to any context XML descriptor embedded inside the application even if the descriptor embedded inside the application is more recent. The flag's value defaults to false. Note if deployXML is false, this attribute will have no effect.

like image 193
Frank Pavageau Avatar answered Oct 16 '22 06:10

Frank Pavageau


As I understand it, the context.xml in META-INF is used unless the element deployXML is set to false. Note from the Tomcat 7 docs, the default is true unless a security manager is enabled!

However, from the docs, I was under the impression that setting the copyXML attribute in the context.xml itself (without touching server.xml) would cause the file to be copied to conf:

<Context antiJARLocking="true" path="/widget" copyXML="true" />

However, using Tomcat 7, it seems that the file doesn't get copied to conf unless the copyXML is set to true on the as Frank answered above.

like image 34
DarthPablo Avatar answered Oct 16 '22 07:10

DarthPablo