Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NoClassDefFoundError when launching servlet via CGI on Tomcat

0 views
Skip to first unread message

James Keeley

unread,
Jan 10, 2002, 4:06:34 AM1/10/02
to
I'm in the process of moving our JRE1.1x CGI-based servlet app to Tomcat and
JRE1.3.1.

I have a servlet that I am launching via CGI (temp. measure during the
upgrade to SSL...) that throws a NoClassDefFoundError exception when trying
to load a servlet via a URL connection. The strange thing is that all of
the code is in the same jar file and the classpath is set properly (ie. it
works fine for the rest code in the jar).

Specifically, the error seems to occur when trying to load a serialised JDBC
object. I thought it might be a driver issue, but I have the appropriate
one for the DB/JRE.

Any ideas as to the direction I should be taking would be appreciated.

TIA!


Jon Skeet

unread,
Jan 10, 2002, 4:49:13 AM1/10/02
to

Well, could you say *which* class isn't being found?

"Serialised JDBC object" sounds like it's probably a bad idea to start
with, to be honest. Most JDBC objects are fairly transient by nature.

--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

James Keeley

unread,
Jan 10, 2002, 5:55:50 AM1/10/02
to
> Well, could you say *which* class isn't being found?
>
> "Serialised JDBC object" sounds like it's probably a bad idea to start
> with, to be honest. Most JDBC objects are fairly transient by nature.
>
> --
> Jon Skeet - <sk...@pobox.com>
> http://www.pobox.com/~skeet/
> If replying to the group, please do not mail me too

The class in question is a called CharacterEncoder (internally written) and
it used to convert byte streams into character objects.

What's odd is that tracing through the code, there is no reference to
instantiating a CharacterEncoder object, so I'm a bit boggled by that.

Sorry, the serialised object is the contents passed to the URL connection
(basically text that is compressed and written to the servlet for
processing) and not a JDBC object per se.

The problem occurs when trying to read back the serialised object:

java.io.StreamCorruptedException: InputStream does not contain a serialized
object
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
<...>


Jon Skeet

unread,
Jan 10, 2002, 8:56:54 AM1/10/02
to
James Keeley <jke...@monsanto.com> wrote:
> > Well, could you say *which* class isn't being found?
> >
> > "Serialised JDBC object" sounds like it's probably a bad idea to start
> > with, to be honest. Most JDBC objects are fairly transient by nature.
>
> The class in question is a called CharacterEncoder (internally written) and
> it used to convert byte streams into character objects.
>
> What's odd is that tracing through the code, there is no reference to
> instantiating a CharacterEncoder object, so I'm a bit boggled by that.

That does indeed seem strange.



> Sorry, the serialised object is the contents passed to the URL connection
> (basically text that is compressed and written to the servlet for
> processing) and not a JDBC object per se.
>
> The problem occurs when trying to read back the serialised object:
>
> java.io.StreamCorruptedException: InputStream does not contain a serialized
> object
> at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
> at java.io.ObjectInputStream.<init>(Unknown Source)
> <...>

I suggest you separate out the problems: check that it's being correctly
received by writing at each end what the stream supposedly contains.
Then compare the two files. The deserialise each file.

James Keeley

unread,
Jan 10, 2002, 9:34:43 AM1/10/02
to

> > What's odd is that tracing through the code, there is no reference to
> > instantiating a CharacterEncoder object, so I'm a bit boggled by that.
>
> That does indeed seem strange.
>
> > Sorry, the serialised object is the contents passed to the URL
connection
> > (basically text that is compressed and written to the servlet for
> > processing) and not a JDBC object per se.
> >
> > The problem occurs when trying to read back the serialised object:
> >
> > java.io.StreamCorruptedException: InputStream does not contain a
serialized
> > object
> > at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
> > at java.io.ObjectInputStream.<init>(Unknown Source)
> > <...>
>
> I suggest you separate out the problems: check that it's being correctly
> received by writing at each end what the stream supposedly contains.
> Then compare the two files. The deserialise each file.
>
> --
> Jon Skeet - <sk...@pobox.com>
> http://www.pobox.com/~skeet/
> If replying to the group, please do not mail me too

Jon, I've been a terrible waste of your time. Seems a BASE64Encoder class
subclassed CharacterEncoder and was being instantiated by an object whose
class was in one of the jar files. The problem was that the package
containing CharacterEncoder was not on the CLASSPATH and a slew of
exceptions ensued.

Once again, I apologise (but appreciate you forcing me to articulate things
to the point where I could pinpoint the problem).

Regs!


Jon Skeet

unread,
Jan 10, 2002, 9:42:50 AM1/10/02
to
James Keeley <jke...@monsanto.com> wrote:
> Jon, I've been a terrible waste of your time. Seems a BASE64Encoder class
> subclassed CharacterEncoder and was being instantiated by an object whose
> class was in one of the jar files. The problem was that the package
> containing CharacterEncoder was not on the CLASSPATH and a slew of
> exceptions ensued.

I'm glad you've got it sorted now :)



> Once again, I apologise (but appreciate you forcing me to articulate things
> to the point where I could pinpoint the problem).

No need to apologise - 90% of the time that forced articulation is what
leads to a "Doh!" moment in all of us. Just glad I was of some use :)

0 new messages