Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Configuring JSF in the TOMCAT/conf/web.xml for all webapps  RSS feed

 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am developing a system in which every webapp deployed to Tomcat uses JSF.
So, I decided to move the common JSF configuration from each webapp/WEB-INF/web.xml
into the TOMCAT/conf/web.xml file.

At startup time everything looks fine. Here's an example of the output I see for each webapp:


However, when the first URL to *.jsf occurs I get the following error message:


If I move the JSF configuration back into each webapp-specific web.xml,
then it works fine. Any ideas why this would happen?

Thanks,
Bryan
 
Tim Holloway
Bartender
Posts: 18705
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A) It doesn't work that way

B) If it did, you'd be at risk for apps interfering with each other. The Java webapp architecture is designed with the idea that effectively, each webapp runs in isolation from the others, rather like virtual machines would. Among other things, they keep discrete classpaths. And, BTW, a WEB-INF/web.xml file is not only required to be within an app's classpath, the actual path location (that is, a file named web.xml inside the /WEB-INF directory of the WAR) is part of the WAR specification and cannot be relocated.

C) Unless I'm greatly mistaken, the TOMCAT_HOME/conf/web.xml file is used for location of the default webapp, and exists primarily for legacy purposes. And/or it registers Tomcat's MIME type database. At any rate, it's best left alone.

On the other hand, in Tomcat, you CAN instantiate the same WAR as multiple webapps. That is, a single WAR file (or exploded WAR) can be referenced by multiple application definitions. Each definition supplies a unique URL context and can have its own JNDI definitions and logfiles, etc.

About the only way for multiple webapps that don't share an entirely common WAR to use the same resources is if they play games with their classpaths. The WEB-INF/web.xml file, however, is read by Tomcat to configure the webapp before any actual application code is loaded or started up, so for that particular item, you'd almost certainly have to modify Tomcat itself.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!