Pretty much and I don't know the reason why that is, I am not in charge of the linux servers I only started looking into it because I couldn't get my method to work but it worked on my local windows environment. The entire web app is classes so its actually a class in WEB-INF\classes, that for some unknown reason the entire package is also sym linked in tomcat\common\classes.
Can you think of any reason why someone would do that? I can only assume that at some point in the past someone else has had classloading issues and decided that that hack would solve it. That is unconfirmed though. Paul -----Original Message----- From: Pid [mailto:p...@pidster.com] Sent: 28 June 2010 14:02 To: Tomcat Users List Subject: Re: Classloading On 28/06/2010 13:48, Ockleford Paul (NHS Connecting for Health) wrote: > Hi, > > Thanks very much for confirming that and for providing me with more > information. One thing I still find strange though is how SupplementaryEdit > (in the webapp) is able to call a class loaded by the "common" classloader? > Does it not work the other way round as well? So, to clarify something, there is a symlink in common/lib which points to a jar which is actually inside your application WEB-INF/lib? p > Thanks, > > Paul > > -----Original Message----- > From: Shay Rojansky [mailto:r...@roji.org] > Sent: 28 June 2010 13:35 > To: Tomcat Users List > Subject: Re: Classloading > > Hi Paul. > > Yes, this is the normal behavior. As you found out, Tomcat uses a > different classloader for the "common" classes than that used for for > loading your webapp classes. > > Basically, when your application loads PracCalc, Tomcat looks first in > the "common" directory and loads it from there. Then, since the > reference to SupplementaryEdit is from PracCalc, PracCalc's classloader (the > "common" > one) is used to search for the dependency, SupplementaryEdit. Since > the "common" classloader knows nothing about your webapp's classes, a > ClassNotFoundException is thrown. > > You have to plan well how to manage your JARs and classes. One > solution is to put all dependencies in your webapp, another is to make > sure that if you put a dependency in Tomcat's common directory, all of > the dependency's dependencies must also be there. > > Shay > > On Mon, Jun 28, 2010 at 8:22 AM, Ockleford Paul (NHS Connecting for > Health) <paul.ocklef...@nhs.net> wrote: > >> 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 >> >> >> ********************************************************************* >> *********************************************** >> > > ********************************************************************** > ********************************************** > > 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 > > ********************************************************************** > ********************************************** > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > ******************************************************************************************************************** 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 ******************************************************************************************************************** --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org