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!
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)
<...>
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, 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!
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 :)