Thanks for the replies, I think I understand what is happening now, I think
for safety's sake I will use a separate config file for each web app instead
of trying to share one between them all and load separate copies.

Thank you. 

-----Original Message-----
From: Mark Thomas [mailto:[EMAIL PROTECTED] 
Sent: 09 May 2008 13:41
To: Tomcat Users List
Subject: Re: Possible to assign different class loader for each web app with
tomcat

[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]



**********************************************************************
This message  may  contain  confidential  and  privileged information.
If you are not  the intended  recipient please  accept our  apologies.
Please do not disclose, copy or distribute  information in this e-mail
or take any  action in reliance on its  contents: to do so is strictly
prohibited and may be unlawful. Please inform us that this message has
gone  astray  before  deleting it.  Thank  you for  your co-operation.

NHSmail is used daily by over 100,000 staff in the NHS. Over a million
messages  are sent every day by the system.  To find  out why more and
more NHS personnel are  switching to  this NHS  Connecting  for Health
system please visit www.connectingforhealth.nhs.uk/nhsmail
**********************************************************************


---------------------------------------------------------------------
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