[EMAIL PROTECTED] wrote:
Ok thanks, it's starting to become clearer now. > The class file is in a jar file that lives in tomcat\shared\lib. I am
guessing that these classes are loaded by a class loader further up the
hierarchy described in the tomcat docs. I suppose in this instance there
would only be one class loaded?

Correct. The class would be loaded once but that doesn't prevent multiple instances of the class being created. However, I suspect the class in question uses the singleton pattern so there is also only once instance. This instance will be shared between all webapps.

I guess if this is the case the only thing confusing me is why this class is
actually loaded by tomcat when it doesn't have to be? Does the
<load-on-startup>1</load-on-startup> tag not load a class specifically for
this web app regardless of where the class file might be?

No. load-on-startup requires Tomcat to load the servlet when the context starts and the number dictates the order (as per the spec). The class loaders will be searched in the order described in the docs and the first instance found of the class will be used.

If (as it appears from your description) you have webapp specific information being held in a singleton class then you *must* place that class in WEB-INF/classes or the jar containing it in WEB-INF/lib

shared/lib is for classes that can be safely shared between multiple webapps. Personally I never used it. It generally caused more problems than it solved - one of the reasons it is removed by default in 6.0.x onwards.

Thanks for the help by the way.

No problem.

Mark

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to