logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cakalic, James" <James.Caka...@Maritz.com>
Subject RE: InvalidClassException
Date Thu, 24 Oct 2002 15:41:29 GMT
Let me preface this by saying that I've used serialization lots of times
on objects passed between an application server and Java client (using
RMI/IIOP) when those objects contained private static Logger (or
Category) fields. So I'm sure it can be done.

Did you deploy the new class to both the server and the RMI client? Most
of the time this is the problem. The class definition has apparently
changed by the addition of the static field. According to the
Serialization Spec, "If not specified by the class, the
value [serialVersionUID] returned is a hash computed from the class's
name, interfaces, methods, and fields using the Secure Hash Algorithm
(SHA) as defined by the National Institute of Standards." Although
private static fields are _supposed_ to be ignored when computing the
hash, this may be a defect with either the server or client runtime jvm.
Also, the class initialization method, if it exists, _is_ part of the
hash. So, and I'm going out on a limb here, if this is the first static
field or the first one with a declared initializer, a <clinit> method
may have been added to the class. Also, if you've made any other code
changes in concert with adding the static field these may be changing
the UID of the class.

Were both the server class and client class compiled using the same
compiler? Compilers oftimes 'synthesize' various data members. Each
compiler does this differently. That means that the same class compiled
by two different compilers could have different values for
serialVersionUID. This was a real problem for my team using VisualAge
for Java. There was the IDE-internal compiler, a different compiler that
was used by the IDE for export, the JDK javac compiler, and then we were
using a version of jikes to speed up the builds. Each of these produced
differing class definitions.

Have you tried explicitly setting the serialVersionUID of the class?
This is a private static final long field. This prevents the hash
calculation as I indicated above. You can use the serialver utility (try
'serialver -show') to determine an appropriate value to use. Also, you
can use this utility to see whether the serialVersionUID of the class
seen by the server and the class seen by the RMI client have the same
computed UID. See the JDK docs and Serialization Spec for more details
on serialver.

Serialization Spec (HTML and PDF)

Best regards,
Jim Cakalic

-----Original Message-----
From: Lu, David [mailto:dlu@tiaa-cref.org]
Sent: Thursday, October 24, 2002 10:15 AM
To: 'Log4J Users List'
Subject: RE: InvalidClassException

Does this mean I cannot pass objects which have log4j loggers in them
the wire?

Is there a way around this?

-----Original Message-----
From: Daniel Serodio [mailto:daniel@checkforte.com.br]
Sent: Thursday, October 24, 2002 11:09 AM
To: Log4J Users List
Subject: Re: InvalidClassException

AFAIK, Logger is not serializable.

On Thu, 2002-10-24 at 11:56, Lu, David wrote:
> Can someone please help?
> I'm guessing that the problem I'm seeing is rather common...
> I am running on WebLogic7 and have put log4j into a small test app.
> Prior to adding log4j, everything runs fine.
> After putting in log4j into a State class that is passed from the
> side to my rmi client, I begin to see errors.
> My State.java has something like:
> private static Logger log = Logger.getLogger(
> "org.tiaa.logpoc.catalog.statecatalog.model.State" );
> The errors I begin to see are:
> java.io.InvalidClassException:
> org.tiaa.logpoc.catalog.statecatalog.model.State;
>  Local class not compatible: stream classdesc
> serialVersionUID=-3079158992661169
> 117 local class serialVersionUID=7923177255097461199
>         at
> java.io.ObjectStreamClass.validateLocalClass(ObjectStreamClass.java:5
> 18)
>         at
>         at
> java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java
> :931)
>         at
>         at
>         at
> weblogic.rjvm.ClassTableEntry.readExternal(ClassTableEntry.java:29)
>         at
> java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1207)
>         at
>         at
>         at
> weblogic.rjvm.InboundMsgAbbrev.readObject(InboundMsgAbbrev.java:65)
>         at
>         at
> weblogic.rjvm.MsgAbbrevJVMConnection.readMsgAbbrevs(MsgAbbrevJVMConne
> ction.java:202)
>         at
> weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputS
> tream.java:193)
>         at
> weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:641)
>         at
> weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:488)
>         at
> weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:3
> 68)
>         at
> weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:
> 23)
>         at
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
> --------------- nested within: ------------------
> weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
> creating
> response stream ] - with nested exception:
> [java.io.InvalidClassException:
> org.tiaa.logpoc.catalog.statecatalog.model.State
> ; Local class not compatible: stream classdesc
> serialVersionUID=-307915899266116
> 9117 local class serialVersionUID=7923177255097461199]
>         at
> weblogic.rjvm.MsgAbbrevJVMConnection.readMsgAbbrevs(MsgAbbrevJVMConne
> ction.java:212)
>         at
> weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputS
> tream.java:193)
> **********************************************************************
> This message, including any attachments, contains confidential
intended for a specific individual and purpose, and is protected by law.
you are not the intended recipient, please contact sender immediately by
reply e-mail and destroy all copies.  You are hereby notified that any
disclosure, copying, or distribution of this message, or the taking of
action based on it, is strictly prohibited.
> **********************************************************************
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:
Daniel Serodio

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

<font size="1">Confidentiality Warning:  This e-mail contains information intended only
for the use of the individual or entity named above.  If the reader of this e-mail is not
the intended recipient or the employee or agent responsible for delivering it to the intended
recipient, any dissemination, publication or copying of this e-mail is strictly prohibited.
The sender does not accept any responsibility for any loss, disruption or damage to your data
or computer system that may occur while using data contained in, or transmitted with, this
e-mail.   If you have received this e-mail in error, please immediately notify us by return
e-mail.  Thank you.

To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>

View raw message