Carl Rosenberger wrote:
> 
> > When adding c:\java\my-web-app-dir\web-inf\classes to CLASSPATH
> > Tomcat is loosing the jars in my c:\java\my-web-app-dir\web-inf\lib
> 
> Hi Niv,
> 
> we have also spent 2 days last week to debug this problem, since a user of
> our object database had problems to get in running.
> 
> The setup:
> The jar of our engine was registered in the global CLASSPATH. The user had
> his classes in ..\project-dir\web-inf\classes (not in the CLASSPATH). The
> phenomena was very interesting:
> The classes would work O.K. but our engine got a ClassNotFoundException
> calling Class.forName() for all web-inf\classes when it was invoked from the
> init() of the servlet.
> 
> Two workarounds were possible:
> - ..\project-dir\web-inf\classes added to the CLASSPATH
> - placing all Jars in ..\project-dir\web-inf\lib
> 
> Maybe the second solution might work our for you.
> 
> I would also consider the behaviour to be a Tomcat bug.

Isn't this due to how the classloaders work in a servlet container?
Classloaders in Servlet 2.2 spec containers don't look down for classes,
they look 'up'.  So a class in WEB-INF/lib won't be found by a class
instantiated in an upper level loader.

That's why it works when you put everyting in WEB-INF/lib or put
/classes in teh CLASSPATH, as that makes everything accessable to the
top-level loader.

IMHO, putting things in WEB-INF/lib is the best way, as that makes your
webapp more portable - it doesn't depend upon the CLASSPATH (which is
evil :).  

geir

-- 
Geir Magnusson Jr.                           [EMAIL PROTECTED]
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Reply via email to