Hi Charlie, 

I gave it a try.  And guess what: it worked!  Now, in this very simple case
one can argue that adding the collection classes to the application's lib
directory is not a bad thing to do.  But what would one do if the scenario
wasn't that simple? (Actually, it isn't!) 

Anyway, I consider this still a bug in the classloader hierarchy!  

So, where do we go from here? 


--- Jürgen

NB: As for your concerns with loading the classes more than once: I think
that's what classloaders are for: I would always let it be their problem... ;-)

NB(2): Actually, the problem already shows up when an application is
serializing a hashtable that contains an object of a class that is defined in the
application only. - Yet one reason why I think that's a bug in the classloader
hierarchy. 

----------- original post ------------

ok, StandardClassLoader means that the class is trying to be loaded from
\tomcat\lib. If it were being loaded from \web-inf\lib, it would be
WebappClassLoader throwing the error.

>From your stack trace, it looks as if it is loading the Hashtable
ok(through
reflection), but it is the contents of the hashtable that can't be loaded.
This would make sense since you put the Hashtable in \tomcat\lib.

How about if you try to put Hashtable in the \web-inf\lib so that the first
reflection call will find it in the current(webapp) classloader, then the
second reflection call(from hashtable) will occur in your webapp's
classloader. Of course being a java class, I'm not sure if it will have
problems being(or can be) loaded multiple times.

Charlie

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 09, 2002 9:07 AM
> To: [EMAIL PROTECTED]
> Subject: RE: RE: Problems with class loader
> 
> 
> see intermixed, too
> 
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Date: Fri, 9 Aug 2002 08:42:05 -0400
> Subject: RE: Problems with class loader
> 
> see intermixed
> 
> >
> > Hello,
> >
> > we have problems with the tomcat class loaders.
> >
> > scenario:
> > Tomcat 4.0.4, jdk1.3
> > 2 Applications
> >
> > App1:webapps/App1/WEB-INF/lib/x.jar
> > App2:webapps/App2/WEB-INF/lib/x.jar (the same .jar-file)
> >
> > x.jar: a.class, b.class, c.class
> >
> > b.class has a Hashtable (com.sun.java.util.collections.Hashtable) as
> > member-variable. (Hashtable is in the directory 
> $CATALINA_HOME/lib/).
> 
> why is hashtable defined in $CATALINA_HOME/lib ? Is there a reason why
> allowing the JVM to provide the java classes is a problem? 
> This shouldn't
> really matter in this case, but could cause problems keeping 
> in sync with
> the current JVM version.
> --> yes, this jar-file doesn't have to defined there but this 
> is not the
> problem
> 
> > In the Hastable are Objects of the c.class.
> >
> > class a in App1 serialize class b and save it in persistence
> > (poet-)classes
> > in directory ($CATALINA_HOME/lib/).
> so, this poet(I'm not familiar with it) is located in 
> $CATALINA_HOME/lib ?
> Is this the class that tries to create an instance of b.class?
> --> no, class a in x.jar tries to create an instance with the
> ObjectInputStream
> 
> If so this is your problem. Classes in the /tomcat/lib or 
> /common/lib can
> *NOT* see classes in the /web-inf/lib directories. Try moving x.jar to
> /tomcat/lib and see if it fixes your problem.
> --> I can`t do it because there are dependances to other 
> classes in the
> application-directory.
> 
> Alternatively you could move poet to each web-inf/lib with 
> x.jar, but they
> need to stay together.
> --> this is also impossible because the poet-classes can only 
> be loaded from
> one class loader.
> 
> jürgen
> 
> Charlie
> 
> > In App2 class a load the serialized class from the
> > persistence classes and
> > deserialize it (--> class b).
> > Then, a ClassNotFoundException (class c) is thrown (see 
> lower). Why???
> >
> > class b and the Hashtable are loaded, but not class c.
> >
> > It is as follows: ?
> > The applicationClassLoader finds the class b and then the
> > StandardClassLoader finds the Hashtable and then (however??) the
> > StandardClassLoader try to load class c. And of course the
> > class loader
> > can't find the class c!
> >
> >
> > thanks
> > jürgen
> >
> >
> >  at
> > org.apache.catalina.loader.StandardClassLoader.loadClass(Stand
> > ardClassLoade
> > r.java:1127)
> >  at
> > org.apache.catalina.loader.StandardClassLoader.loadClass(Stand
> > ardClassLoade
> > r.java:992)
> >  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> >  at java.lang.Class.forName0(Native Method)
> >  at java.lang.Class.forName(Class.java:195)
> >  at 
> java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:654)
> >  at
> > java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStre
> > am.java:918)
> >  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
> >  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
> >  at 
> java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
> >  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
> >  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
> >  at
> > 
> com.sun.java.util.collections.Hashtable.readObject(Hashtable.java:773)
> >  at java.lang.reflect.Method.invoke(Native Method)
> >  at
> > java.io.ObjectInputStream.invokeObjectReader(ObjectInputStream
> > .java:2213)
> >  at 
> java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1410)
> >  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
> >  at
> > java.io.ObjectInputStream.inputClassFields(ObjectInputStream.j
> > ava:2262)
> >  at
> > java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.
> > java:519)
> >  at 
> java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1411)
> >  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
> >  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
> >
> > --
> > GMX - Die Kommunikationsplattform im Internet.
> > http://www.gmx.net
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> -- 
> GMX - Die Kommunikationsplattform im Internet.
> http://www.gmx.net
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:  
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to