Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

How do you get Tomcat 4.x to use the same classloader for a web-app's servlets and JSP's?

Michael Reilly

2004-01-15

Replies:

How do you get Tomcat 4.x to use the same classloader for a web-app's servlets

and JSP's?



I have a class that initialises logging, constants, database settings,

resource bundles, property files etc.



I setup the web.xml to load the servlet on startup, which setups the class

correctly.



I was recieving some funny messages about missing resource bundles in the JSP

while it looked fine in servlet.



I put some Log4j logging into the static init method of the constant class.



Then, I loaded the servlet, which worked. After giving it about 10 or so

seconds, I loaded the JSP, which failed.



When I checked the logs, I saw quickly what was happening. The servlet was

being loaded twice. Upon checking the class loader faq and other

documentation, I found a note that says JSP's are loaded in a different

classloader!!



2004-01-16 11:34:18,419 [utils.Constants] [INFO ] [] *******************

Servlet initialisation starting

2004-01-16 11:34:18,419 [utils.Constants] [INFO ] [] Loading Constants

2004-01-16 11:34:29,252 [utils.Constants] [INFO ] [] *******************

Servlet initialisation starting

2004-01-16 11:34:29,268 [utils.Constants] [INFO ] [] Loading Constants



Something to do with PropertiesResourceBundles seems to stop them being loaded

successfully by two different class-loaders.



Does anyone have any suggestions on a) how to fix this glaring problem, or b)

obtain a reference to the JSP class loader so I can load config and properties

resource bundles through it?


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.