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

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

Reply via email to