You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Matt Koss <m....@open.ac.uk> on 2003/05/15 13:48:44 UTC

dynamic class loading problem in 4.1.24

I am trying to upgrade from tomcat 4.0.6 to 4.1.24
Suddenly I experience problem with a classloader behaviour.

My web application uses a library A.jar and in runtime loads class from the 
file plugin.jar.
With 4.0.x I put the file A.jar into common/lib directory and everything 
worked ok. Servlet class from A.jar was loaded at the beginning and then 
plugin.jar was dynamically loaded.

With 4.1.24 the classes from A.jar are not visible when loading plugin.jar ( I 
am using JarClassLoader class) and I have to put A.jar into the central 
"jre/lib/ext" directory.

This is somehow not acceptable, but I would really like to stick with 4.1.24.

Any advice ?

Thanks

Matt

-- 
Matt Koss
Knowledge Media Institute
Open University
tel: +44 1908 659399

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


Re: dynamic class loading problem in 4.1.24

Posted by Matt Koss <m....@open.ac.uk>.
plugin.jar is a file loaded dynamically (using class JarClassLoader) from 
within the application and is in the special directory "plugins".
Class plugin.jar contains class MetaIOPlugin that extends class IOPlugin from 
the file A.jar.

When I use Tomcat 4.1.24, and trying to dynamically load class MetaIOPlugin 
from the file plugin.jar, I get an error message saying :

java.lang.NoClassDefFoundError: edu/ou/kmi/apollo/core/IOPlugin

This worked without problems in Tomcat 4.0.6 !
Now it seems that when I use JarClassLoader, classes in the jar files in any 
of the directories lib, common/lib, server/lib or WEB-INF/lib are not visible 
at all.

Matt


On Thursday 15 May 2003 1:07 pm, Jacob Kjome wrote:
> So, you are saying A.jar is in common/lib and plugin.jar is in
> WEB-INF/lib?  In that case plugin.jar will be able to see A.jar, but not
> vice-versa.  This is because of Java2 ClassLoader rules.  Classloaders
> higher in the hierarchy can't see ClassLoaders lower in the
> hierarchy.   The only ways around this are using the lib/ext as you've
> done, putting both jars in the same classloader (recommended), or making
> sure that the A.jar uses the thread context classloader to be able to see
> classes in other classloaders.
>
> Jake

>
> At 12:48 PM 5/15/2003 +0100, you wrote:
> >I am trying to upgrade from tomcat 4.0.6 to 4.1.24
> >Suddenly I experience problem with a classloader behaviour.
> >
> >My web application uses a library A.jar and in runtime loads class from
> > the file plugin.jar.
> >With 4.0.x I put the file A.jar into common/lib directory and everything
> >worked ok. Servlet class from A.jar was loaded at the beginning and then
> >plugin.jar was dynamically loaded.
> >
> >With 4.1.24 the classes from A.jar are not visible when loading plugin.jar
> >( I
> >am using JarClassLoader class) and I have to put A.jar into the central
> >"jre/lib/ext" directory.
> >
> >This is somehow not acceptable, but I would really like to stick with
> > 4.1.24.
> >
> >Any advice ?
> >
> >Thanks
> >
> >Matt
> >
> >--
> >Matt Koss
> >Knowledge Media Institute
> >Open University
> >tel: +44 1908 659399
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

-- 
Matt Koss
Knowledge Media Institute
Open University
tel: +44 1908 659399

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


Re: dynamic class loading problem in 4.1.24

Posted by Jacob Kjome <ho...@visi.com>.
So, you are saying A.jar is in common/lib and plugin.jar is in 
WEB-INF/lib?  In that case plugin.jar will be able to see A.jar, but not 
vice-versa.  This is because of Java2 ClassLoader rules.  Classloaders 
higher in the hierarchy can't see ClassLoaders lower in the 
hierarchy.   The only ways around this are using the lib/ext as you've 
done, putting both jars in the same classloader (recommended), or making 
sure that the A.jar uses the thread context classloader to be able to see 
classes in other classloaders.

Jake

At 12:48 PM 5/15/2003 +0100, you wrote:

>I am trying to upgrade from tomcat 4.0.6 to 4.1.24
>Suddenly I experience problem with a classloader behaviour.
>
>My web application uses a library A.jar and in runtime loads class from the
>file plugin.jar.
>With 4.0.x I put the file A.jar into common/lib directory and everything
>worked ok. Servlet class from A.jar was loaded at the beginning and then
>plugin.jar was dynamically loaded.
>
>With 4.1.24 the classes from A.jar are not visible when loading plugin.jar 
>( I
>am using JarClassLoader class) and I have to put A.jar into the central
>"jre/lib/ext" directory.
>
>This is somehow not acceptable, but I would really like to stick with 4.1.24.
>
>Any advice ?
>
>Thanks
>
>Matt
>
>--
>Matt Koss
>Knowledge Media Institute
>Open University
>tel: +44 1908 659399
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org