File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes different classpath for context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "different classpath for context" Watch "different classpath for context" New topic

different classpath for context

Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222

I am running an application for multiple clients and the setup is like the set of classes being used are common and the property files are different for each client. The structure looks as below :
/usr/local/common_application_classes/ - this folder contains all classes
/usr/local/properties/client1/ - this folder contains properties of client1
/usr/local/properties/client2/ - this folder contains properties of client2
...... etc for all the different clients.

Now, this is a web based application and the classes in the /usr/local/common_application_classes/ are being used from the web application (servlet, jsp files). The properties files are being used from the classes contained in the /usr/local/common_application_classes/ folder.

I want to setup a common tomcat for all these clients, but how should I setup the classpath? /usr/local/common_application_classes/ should be in tomcat's classpath. But, properties files are different for different classes, so thought of creating single tomcat and under that, multiple contexts, one for each client and the properties files goes in the respective client's context/WEB-INF/classes. But, since the classes accessing the properties files are outside tomcat (not in context/WEB-INF/classes), are not being able to access properties files - gives MissingResourceException.

Let say, I have a test.jsp file in context /test, which calls a TestClass.class file and this TestClass.class file is looking up some property file through ResourceBundle. The property file is in /test/WEB-INF/classes/ directory. Now, if the TestClass.class is in /test/WEB-INF/classes, then it works perfectly fine, but if the TestClass.class is outside tomcat (included in tomcat's classpath), then it gives MissingResourceException while looking up property file.

Please tell me how can I proceed further?

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
Tomcat does NOT use the environment classpath at all. There is a detailed discussion of how Tomcat finds files
at this site for Tomcat 5 (and there is a similar one for Tomcat 4)
I agree. Here's the link:
subject: different classpath for context
It's not a secret anymore!