tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ockleford Paul (NHS Connecting for Health)" <paul.ocklef...@nhs.net>
Subject Classloading
Date Mon, 28 Jun 2010 12:22:16 GMT
Hi,

I had a problem this morning that took me a while to sort out, and now I know what the issue
is I was hoping somebody could explain why the problem was happening. I assume it is because
one class had been loaded by a different classloader, and so wasn't available to the second
class.

I have 2 classes in different packages but within the same web application:

SupplementaryEdit - webapps/WEB-INF/classes
PracCalc - webapps/WEB-INF/classes

I added a method to SupplementaryEdit and then called it within this class and it worked ok.
Next I created an object of SupplementaryEdit in PracCalc and tried to call this new method.
I got a classnotfoundexception for SupplementaryEdit at the point of instantiation and I was
struggling to find out why.

After spending ages trying different things I started looking through the common classes in
tomcat and found that someone had previously created a symlink to the package PracCalc is
in there. I read a little on tomcat classloading and came to the conclusion that this was
causing PracCalc to be loaded by a different loader to SupplementaryEdit.

If someone could confirm this that would be good, and also could someone explain why the class
in the web app isn't available to the class referenced in common/lib?

I don't understand because I get a runtime exception in the block where the object is created,
and not on initial class use (as I used the class without triggering the code block fine),
and I also don't understand why at runtime the common classloader is not able to resolve the
class, as I have tested by calling a class that creates a SupplementaryEdit object before
trying from PracCalc and it still didn't work.

To resolve the issue I moved the method into PracCalc as this still made sense logically and
the code now works, just looking for some general help\guidance.

Thanks,

Paul

********************************************************************************************************************

This message may contain confidential information. If you are not the intended recipient please
inform the
sender that you have received the message in error before deleting it.
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.

Thank you for your co-operation.

NHSmail is the secure email and directory service available for all NHS staff in England and
Scotland
NHSmail is approved for exchanging patient data and other sensitive information with NHSmail
and GSI recipients
NHSmail provides an email address for your career in the NHS and can be accessed anywhere
For more information and to find out how you can switch, visit www.connectingforhealth.nhs.uk/nhsmail

********************************************************************************************************************

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message