You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Christophe Warland <cw...@mail.com> on 2000/07/22 00:16:35 UTC

WEB-INF/classes class loader problem (3)

[My first and second posts didn't show up after one day so I am
resending. Sorry for duplicates. Next time I'll have to use FedEx or DHL
if the email doesn't go through... grrbl...]

My config:  NT 4 SP5, Tomcat 3.2 b2, Apache 1.3.12 + SSL + mod_jk, Ajp12
and Ajp13, jdk1.2.2 + HotSpot 2.0

I am using http://jdbm.sourceforge.net to store persistent data (my
"Rewards") in my servlets and I have a ClassNotFoundException problem.
Maybe it is a bug in JDBM, but since Tomcat is the one playing with the
classloaders, I guess it might be the culprit. Basically, JDBM serialize
the state of my objects in a persistent hashtable on my hard drive and
then loads the object back when I need it. The ClassNotFoundException
appears when I am loading/getting it back.

Here is my StackTrace:

java.lang.ClassNotFoundException:
com.s1.exc.tintagel.producthandler.Rewards
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:981)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
at java.util.HashSet.readObject(HashSet.java:246)
at java.lang.reflect.Method.invoke(Native Method)
at
java.io.ObjectInputStream.invokeObjectReader(ObjectInputStream.java:1685)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1165)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
at jdbm.hash.HashBucket.readExternal(HashBucket.java:270)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1004)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
at jdbm.recman.RecordManager.byteArrayToObject(RecordManager.java:266)
at jdbm.recman.RecordManager.fetchObject(RecordManager.java:214)
at jdbm.hash.HashDirectory.get(HashDirectory.java:170)
at jdbm.hash.HTree.get(HTree.java:116)
at jdbm.HTreeWrapper.get(JDBMRecordManager.java:270)
at
com.s1.exc.tintagel.producthandler.CachedSummaryHandler.processCommunication(CachedSummaryHandler.java:55)

Of course, both "Rewards.class" and "CachedSummaryHandler.class" are in
my WEB-INF/classes/com/s1/exc/tintagel/producthandler directory.

I first tried to modify my CachedSummaryHandler and add a field like
this to help the class loader:

   Class clazz = Rewards.class;

but it surprisingly didn't help. So I modify tomcat.bat and added the
WEB-INF/classes directory in the overall Tomcat classpath and it worked.
But this is very frustrating because I am running multiple versions of
the same application in Tomcat, and now they all must use the same
persistent classes for all my milestones. Any idea of what is going
wrong?

Thanks,

Christophe

Re: WEB-INF/classes class loader problem (3)

Posted by Christophe Warland <cw...@mail.com>.
Thank you, Costin, for your interest and suggestions. Copying the the jdbm jar
file into the WEB-INF\lib directory solved my problem.

Cheers,

Christophe


Re: WEB-INF/classes class loader problem (3)

Posted by Costin Manolache <cm...@yahoo.com>.
> My config:  NT 4 SP5, Tomcat 3.2 b2, Apache 1.3.12 + SSL + mod_jk, Ajp12
> and Ajp13, jdk1.2.2 + HotSpot 2.0
>
> I am using http://jdbm.sourceforge.net to store persistent data (my
> "Rewards") in my servlets and I have a ClassNotFoundException problem.
> Maybe it is a bug in JDBM, but since Tomcat is the one playing with the
> classloaders, I guess it might be the culprit. Basically, JDBM serialize
> the state of my objects in a persistent hashtable on my hard drive and
> then loads the object back when I need it. The ClassNotFoundException
> appears when I am loading/getting it back.

Where is the code that loads the data ?

Do you have jdbm in the classpath or is it part of WEB-INF/lib ?

The problem seems to be that the "system" class loader is used to
load the files instead of the webapp's class loader.

Costin