You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jose Maria Ramirez Martinez <jr...@veridico.net> on 2005/10/06 17:01:06 UTC

Re: Non-servlet class cannot access jar file in ./WEB-INF/lib whena Servlet does

Hi David, 
thank you very much for the time you took to answer this
do you (or anybody in the mail-list) think there's a way to solve this problem? 
a solution is the one I've mentioned before: unpacking the jar classes and add them to the /WEB-INF/classes directory, and there is no problem when loading classes, but do you think there might be another solution, without unpacking jars??
thanks again.

Jose Maria.

---------- Original Message ----------------------------------
From: David Delbecq <de...@oma.be>
Reply-To: "Tomcat Users List" <to...@jakarta.apache.org>
Date:  Thu, 06 Oct 2005 16:06:49 +0200

>Hi,
>
>all classes of a webapp which do not come from tomcat server itself
>do share a common classloader which is an aggregation of the various
>classes in all WEB-INF/lib/*.jar and in WEB-INF/classes/**/*.class
>
>If you get a NoClassDefFoundException, that probably mean you asked some
>class in server classloader to load some other class (probably by
>reflection) which
>is located in WEB-INF/lib.  That simply impossible to do because
>classloaders use
>a child to parent classloading delegation model, not a parent (server)
>to child (webapp).
>
>Regards
>David Delbecq
>Jose Maria Ramirez Martinez a écrit :
>
>>Hi, everybody
>>
>>I have the next problem:
>>A servlet calls a non-servlet class, and this non-servlet class imports classes from a jar file, 
>>but the classloader does not find the class from the jar file
>>(so when I call the servlet from an internet browser, I get a NoClassDefFoundException)
>>
>>But if a servlet class imports the same classes from the jar, the class loader does find them...
>>I've tried some ways to solve this problem, like:
>>   a) unpacking the classes from the jar (this works, but I had the problem that 2 different jars contained 
>>a file with the same name stored in the same directory, so one would replace the other, and the class fails)
>>   b) I thought it would be a security problem so I ran tomcat with a SecurityManager, but it didn't solve the 
>>problem..
>>
>>does somebody has any idea why this is happening???
>>can somebody help me to solve this... thanks in advance
>>
>>Jose Maria
>>
>>
>>___________________________________________________________
>>$0 Web Hosting with up to 200MB web space, 1000 MB Transfer
>>10 Personalized POP and Web E-mail Accounts, and much more.
>>Signup at www.doteasy.com
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>  
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



___________________________________________________________
$0 Web Hosting with up to 200MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org