Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Context Question

 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am upgrading from Tomcat 4 to Tomcat 6, and the concept of $CATALINA_HOME/conf/context.xml is confusing to me.

If we want to have multiple web applications running on a server, how can we list these in the $CATALINA_HOME/conf/context.xml file? Every time I try and put multiple context entries in this file I get a parse error on startup. Are we only allowed to have one context entry in this file?

If so, why would anyone ever use this as opposed to putting the context.xml into META-INF under webapps?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See:
http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html#A%20word%20on%20Contexts

They go in tomcat/conf/Catalina/localhost/[context-name].xml

If you have configured your own host, replace the 'Catalina/localhost' part accordingly.


... why would anyone ever use this as opposed to putting the context.xml into META-INF under webapps?


You can still place a context.xml file in your META-INF diretory if you like. Just to be clear, the META-INF directory is under webapps/[context-name]/META-INF.

When I'm developing apps, I keep the code base outside of the tomcat hierarchy. Using context fragment files makes it easy to separate the two.


Lastly, don't try to put more than one context entry in a context fragment file. Each application should have its own file named [context-name].xml
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben,

Thanks for the reply. Putting the context information in tomcat/conf/Catalina/localhost/[context-name].xml will work fine for me.

However I still don't understand the point of tomcat/conf/context.xml. Is this for "global" context information? Meaning you can't put docBase or path attributes in here...because the context entry applies to all contexts?

Thanks,
Jim
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Ellis:
However I still don't understand the point of tomcat/conf/context.xml.

Where are you reading about this file?
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben,

I am reading about it here.

There was also already a blank tomcat/conf/context.xml already in my installation of tomcat when I unpacked the zip for Tomcat 6.0.16.

Jim
[ March 02, 2008: Message edited by: James Ellis ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see.
It says that the element information here will be shared by all web apps.
I've never used it but I'm taking that to mean that this would be a place to put settings that will be common to all of them.
The same way you can put common settings into the tomcat/conf/web.xml descriptor.
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben,

I'll be following your advice and putting the context information in tomcat/conf/Catalina/localhost/[context-name].xml

Thanks,
Jim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic