To serialVersionUID or Not To serialVersionUID?

Eclipse IDE 3.1 warns me on my Serializable classes that there is no serialVersionUID field specified. I am familiar with java Serialization mechanism and why this speed up serialization, but can anyone tell me the effects managing your own serialVersionUID has in large enterprise applications?

Yes it is faster. Also if you omit it in the first
deployment you will never be able to version the
class.I dont think so
if you do not define a serialVersionUID a serialVersionUID will be calculate automaticaly and it is done only once per application session so it is not much performance loss.
And the same time if you deploy for the first time without defining a serialVersionUID and if you later want to define a the value while keeping the backword compatibility all you got to do is define the value to be same as the value of the first version.
There was a tool in java to get the serialVersionUID of a class but I dont remember its name.
Once this happened to me I have deployed a class with a defined serialVersionUID but I have actual misspelled serialVersionUID so I noticed that only once I deploy the next version and then projram stoped working. But I managed to fix that be setting the serialVersionUID of the new version to be same as the old class

Similar Messages

  • SerialVersionUID's not matching

    Hi, here's my exception:
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.io.InvalidClassException: com.tsc.model.courts.County; local class incompatible: stream classdesc serialVersionUID = -2433655832140195139, local class serialVersionUID = -5449895978211640294
    at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
    at sun.rmi.transport.Transport$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
    at com.inteflux.Session.SessionManager_Stub.putObject(Unknown Source)
    at com.inteflux.Session.SessionControlBean.putValue(SessionControlBean.java:116)
    at com.tsc.action.AbstractUserAction.putSessionValue(AbstractUserAction.java:69)
    at com.tsc.action.agent.TimedBookOrderAction.payment(TimedBookOrderAction.java:172)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:353)
    at com.opensymphony.xwork.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:208)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:182)
    at com.tsc.interceptor.webwork.HibernateInterceptor.intercept(HibernateInterceptor.java:35)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor.intercept(DefaultWorkflowInterceptor.java:117)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.webwork.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:171)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:146)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:94)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:119)
    at com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(DispatcherUtils.java:233)
    at com.opensymphony.webwork.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:198)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.io.InvalidClassException: com.tsc.model.courts.County; local class incompatible: stream classdesc serialVersionUID = -2433655832140195139, local class serialVersionUID = -5449895978211640294
    at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
    at sun.rmi.transport.Transport$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.InvalidClassException: com.tsc.model.courts.County; local class incompatible: stream classdesc serialVersionUID = -2433655832140195139, local class serialVersionUID = -5449895978211640294
    at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
    at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
    at java.io.ObjectInputStream.readClassDesc(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
    at java.io.ObjectInputStream.readSerialData(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    at sun.rmi.server.UnicastRef.unmarshalValue(Unknown Source)
    Now I know that means that the two version of the class are different but I don't see how. The class is only located in one place on the server, so how is it possible that it's different? Any help would be appreciated because I'm at a loss as to what to do or even how to search for the problem.
    I have tried to set the UID manually, but that didn't help. I also am using netbeans and deleted the old classfiles to force it to recreate them again and that didn't work either.
    I'm using a session bean to put a class in the session. The error is being generated by a class variable that is within the main class to be serialized. Not sure if maybe that has something to do with it.

    Now I know that means that the two version of the
    class are different but I don't see how.
    The class is only located in one place on the server,
    so how is it possible that it's different?Did you modify the source file for that class at some point?
    Basically, if you never explicitly specified a "serialVersionUID"
    in the Java source code, then every time you compile it,
    the Java compiler will assign a serialVersionUID for you,
    based on the fields you have in your class.
    So that's very fragile: if you modify the source file for that class,
    then suddenly the UID may change, and you won't be able
    to deserialize a object that you previously serialized.
    The lesson: for every serializable class,
    you should explicitly give it a UID.
    It doesn't matter what value you choose. Can be 0.
    As long as you choose a value, then the compiler
    won't change it back and forth.
    As for your particular recovery: it seems you have some
    serialized objects that you want to read back.
    Did you change the fields between last time and this time?
    If you didn't, then just find out what UID value was chosen by the compiler.
    Then you write that UID into your source file and recompile.
    That should allow you to read-back your old objects.
    (But if you've added or removed a field since the last time,
    then clearly the default serialization should NOT work.
    You would need to read about "readResolve" and
    other advanced methods for how to deserialize
    an out-of-date file)

  • Java.io.InvalidClassException: org.eclipse.persistence.internal.indirection.DatabaseValueHolder; local class incompatible: stream classdesc serialVersionUID = -6893195210780291759, local class serialVersionUID = 1128857921468654749

    Hi,
    I recently create a webservice application.
    It work fine when the server is implemented as java application. But when rewritten as web application( *.war),  the deploiement work on WLS.
    However it throws java.io.InvalidClassException: org.eclipse.persistence.internal.indirection.DatabaseValueHolder; local class incompatible: stream classdesc serialVersionUID = -6893195210780291759, local class serialVersionUID = 1128857921468654749 error when the client start consumming the web service methods.
    I add both eclipselink-javax.persistence-2.0.jar and eclipselink-2.0.2.jar(which are also used in the server side) in $WL_HOME/wlserver_10.3/common/deployable-libraries, that doesn't solve the problem yet.
    Any help will be appreciated, cheers.

    Abenk,
    This looks like a serial version mismatch due to multiple Eclipselink.jar files. Check if you have any under server/internal/ext folder.
    What are you putting in your classpath? Is there a "jrf.jar" and is it getting picked up first? Does this Jrf.jar have an entry of Eclipselink jar?
    Try to check the classpath of the jars used by Weblogic and remove any redundant Eclipselink/Toplink jars.
    What is the complete version of your Weblogic Server ?

  • 10g preview SerialVersionUID

    I am devloping an app using JAXB in jdev 10g. I added the JAXB libraries from JWSDP-1.3 to my project along with some jaxb source code I compiled with JWSDP. I am using JWSDP so I can use the xjc serializable extension to be able to store my classes as cmp fields.
    When I use the embedded oc4j that comes with jdev 10g preview the app works fine. When I deploy to a standalone version of the same oc4j along with the same added libraries, it also works as expected. But when I deploy to the standalone 10g oc4j preview, along with the same added libraries, using this type of code:
    ObjectFactory objFactory = new ObjectFactory();
    MyObjectType myObject = objFactory.createMyObjectType();
    I am getting an error saying:
    java.lang.InternalError: com.sun.msv.datatype.xsd.XSDatatypeImpl; local class incompatible: stream classdesc serialVersionUID = 1, local class serialVersionUID = 48001797565480860 at com.sun.xml.bind.unmarshaller.DatatypeDeserializer.deserialize(DatatypeDeserialer.java:30)
    Strangely it does not happen on most of the jaxb classes I try to invoke, only a few. I believe the error means that there is a different version some JAXB implementation classes in the OC4J preview than I added to the default embedded oc4j. Can anyone point me in the right direction on how to fix this?

    I have a little more information. The problem was being caused by a custom datatype which used the <union/> tag. I'm still a little puzzled why it works in jwsdp-1.3 and the embedded version, but not the 10g preview. Does anyone know what libraries I can move from JWSDP-1.3 into oc4j 10g preview to get the union tag to work?

  • SerialVersionUID in Java 1.4.2 and 1.5

    Hi!!!
    Just ny curiosity: I�ve took a look at the API documentation for Java 1.5 and, as you can see here in [url http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html]Serializable&#9733;, according to the documentation:
    If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, [i]it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization. Therefore, to guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value. It is also strongly advised that explicit serialVersionUID declarations use the private modifier where possible, since such declarations apply only to the immediately declaring class--serialVersionUID fields are not useful as inherited members.
    Well, the fact is that in API Docs for [url http://java.sun.com/j2se/1.4.2/docs/api/java/io/Serializable.html]1.4.2 version&#9733; this excerpt does not exist. What does it mean? Would it mean that in 1.4.2 serialVersionUID was not really necessary, and now, with 1.5, it is? Or would Sun simply forget to rewrite the 1.4.2 API Docs, in order to be in conformity with 1.5 Docs?

    Well, they wouldn't rewrite their 1.4 documents at all actually.
    This is just Sun improving their product's documentation. Defining a serialVersionUID has always been a good idea, as all versions of the Serialization Specification show.

  • SerialVersionUID in abstract classes

    Hi,
    i have a Question about the serialVersionUID for abstract classes.
    first i will describe a simple example to show my problem.
    abstract class A implements Serializable {
        private int value;
        public A(int value) {
            this.value = value;
        protected abstract void doSomething();
    class B extends A {
        private static final serialVersionUID = 8373629029L;
        public B(int value) {
               super(value);
        protected void doSomething() {
         //do something
    } B is a ValueObjects on a Server and transmitted to a Client Application.
    When i change the abstract super class A i get an exception on the client because the serialVersionUID does not mathc to the Client anymore
    So i changed the " implements Serializable" Statement down to B. And tried the same. Then i get an InvalidClassException because with following hint "no valid constructor". So i also have to make A Serializable and also need a defined serialVersionUID for A.
    I think there is something i don't unterstand in the serialization Mechanism in Java.
    Why does it makes sense to adda serialVersionUID to an abstract class? And how do i generate the UID with the "serialver" tool deliversd with the JDK form a class which i cannot instanciate?
    Edited by: kbj on Jan 23, 2009 7:14 AM

    kbj wrote:
    So i would like to know what is the best practise in such a case?Classes designed for inheritance should rarely implement Serializable, and interfaces should rarely extend it. If a class or interface exists primarily to participate in a framework that requires all participants to implement Serializable then it makes sense to violate this rule.
    So in your case you may want to provide a protected parameterless constructor and a protected initialization method if a client provided invariant is required ("value" in your case). Then all public or protected instance methods need to call a private method that checks that the class has been initialized (i.e. the subclass has been written so that it calls the protected initialization method and passes in the "value" invariant). If not then you should throw an IllegalStateException. The field you use to flag that the object has been initialized should be of type java.util.concurrent.atomic.AtomicReference.
    The above is taken pretty much verbatim from chapter 11 of effective java second edition. The book also provides an example of the above you could use as a template.

  • InvalidClassException, serialVersionUID

    i am performing dynamic classloading over network (almost).
    however, my final(?) error is such:
    java.io.InvalidClassException.... local class incompatible: stream classdesc serialVersionUID = -17289354839854, local class serialVersionUID = 987654321
    in the class that is being loaded, i "lock-down"(?) the serialVersionUID with:
    static final long serialVersionUID = 987654321;what are some things for me to look at?
    on the client that is trying to load the class, there is no copy of the target class file.
    there really is only one physical class file and it is on the server.
    and it was compiled with serialVersionUID = 987654321.
    and it is marked as final_ .
    where is that crazy serialVersionUID = -17289354839854 coming from?
    thoughts and ideas appreciated.
    Edited by: kappa9h on Nov 25, 2007 6:15 AM

    i am doing a byte-by-byte copy of a class file from the server to the remote ClassLoader
    over a Socket stream. so how is the serial ID changing?
    i read the class file into a byte[] and stream is over the Socket.
    and on the other end of the Socket, the byte[] is exactly the
    same size. so, i am not dropping bytes or re-ordered (its tcp). so i don't know.
    public class MyClassLoader extends ClassLoader {
      public Class findClass(String name) {
        byte[] buf = loadClassData(name);
        return(defineClass(name, buf, 0, buf.length));
      private byte[] loadClassData(String name) {
        Socket sok = new Socket("192.168.0.3", 8877);
        InputStream in = sok.getInputStream();
        byte[] buf = new byte[1048];  // <-- now i cheat and hardwire the correct size
        in.read(buf);
        return(buf);
    }on the other end, server "192.168.0.3", i have a
    ServerSocket listening on *8877.*
    when it is connected to, i read: *"/tmp/myClass.class"* into a byte[]
    and send it over the Socket.

  • Zero serialVersionUID

    I have a program that writes a serialized object to a socket and another that reads it. This code has been working in production for years. In our development environment, readObject suddenly started failing, and two days later started working again. The exception (which I can't reproduce anymore) was something like this:
    java.io.InvalidClassException: (my class); Local class not compatible: stream classdesc
    serialVersionUID=(big number) local class serialVersionUID=0
    While I could, I reproduced the problem using production jars in the development environment, so it seems unlikely the bug is in our code. I believe a zero serialVersionUID means the object is not Serializable, which of course it is, and always has been. In fact, readObject worked if I set the class's serialVersionUID to zero.
    The writer was Windows NT and java 1.3.0_02; the reader "SunOS 5.6 Generic_105181-20 sun4u sparc SUNW,Ultra-250" and j2sdk1_3_0.
    I would hate for this to happen in production. Does anyone have any ideas?

    I experience the same problem while writing serialized objects to a file. I haven't been able to produce the problem in my development environment and when I try to read from files that does not seem to work in other environments it works fine.
    Another thing that's odd is that the serialVersionUID=0 once appeared in the local class, and after a JVM restart it appeared in the stream classdesc:
    java.io.InvalidClassException: (my class); Local class not compatible: stream classdesc serialVersionUID=4308934548502194097 local class serialVersionUID=0
    java.io.InvalidClassException: (my class); Local class not compatible: stream classdesc serialVersionUID=0 local class serialVersionUID=4308934548502194097
    Does anyone know how to solve this?

  • SerialVersionUID exception error

    I'm getting the following error, when I use WSAD to send a Document from a WSAD server to a Tomcat client. This code was working fine when I was talking from Tomcat to Tomcat. How can I get this fixed ?
    java.io.InvalidClassException: org.apache.xerces.dom.AttributeMap; Local class not compatible: stream classdesc serialVersionUID=-48425980201249810 local class serialVersionUID=8872606282138665383 java.lang.NullPointerException

    hi , had you changed your class since you had tested tomcat to tomcat? The Nullpointer Excp. normally indicates that
    a variable has not been intialized during the readObject-method.
    If not, provide a static final long serialVersionUID by hand. Use serialver from the jdk to get the value. then you could suppress this error. But you have to overwrite readObject to do intialisation for every new (added after serialver was used) Non-Standard(Standard: int,boolean ..) variable like java.util.list or so.
    Hope this helps.
    Greetings Michael

  • SerialVersionUID is ignored

    Hi All,
    I have a Serializable class. When I was trying to read from the stream. I get an error message
    java.io.InvalidClassException: <myclassname>; local class incompatible: stream classdesc serialVersionUID = -3351349509469673246, local class serialVersionUID = -2391829582221285788
    Even though I set the serialVersionUID in my class, it is not considered.
    public static final long serialVersionUID = -2391829582221285788L; Can anybody please help me to find why this ID is not considered.
    Thanks
    Deekshit M

    You are mis-reading the error. It says that the local class (that is, the class file you have at hand) has the serialVersionUID that you gave. The problem is that the serialised version of the data (i.e. received from a remote system or read from a file) has a different serialVersionUID (-3351349509469673246) and that's different from the one in your class.

  • SerialVersionUID and JMS

    Hi everybody,
    First, a brief description of my situation:
    I have a little JMS project created with 2 two servers, who communicate with eachother.
    When the first server (an XP machine) publishes messages to a topic on which te second machine (an NT machine) has listener (MessageBean -> onMessage()) I get an java.io.InvalidClassException and also the following notification: Local class not compatible: stream classdesc serialVersionUID=
    -9134143542090625703 local class serialVersionUID=-5363901495878210611
    Now here is the strange part: When I turn the whole thing around, this means the NT machine publishes and the XP machine receives, everything works just fine.
    I also tried to put in my own serialVersionUID (private final static long serialVersionUID = 1L;) but it didn't change anything (I even kept getting the "old" serialVersionUID, descriped above).
    Can anyone help me with this problem please?
    I am working with JBuilder 7, the messagebroker is SonicMQ and the JDK (on both machines) is 1.3.1
    Thanks in advance

    HI all,
    I'm having more or less the same error message :
    Error unmarshaling return;nested exception is: java.io.InvalidClassException:
    org.omg.CORBA.CompletionStatus; local class incompatible: stream classdesc serialVersionUID = -9047319660881406859, local class serialVersionUID = -6452792514302430967
    I have checked the JVM client and server and they are 1.4.2_04-b05.
    I tryed to use serialver command in order to see if CompletionStatus class is present but the results are following:
    ./serialver CompletionStatus
    Class CompletionStatus not found.
    Should I add the local class serialVersionUID = -6452792514302430967 ?
    But Could you please indicate me how add it?
    Sorry but I'm a junior java user :O)
    Thanks in advance for your help
    Best Regards

  • SerialVersionUID mismatch

    Hello:
    I get a SerialVersionUID mismatch, during argument unmarshalling for the
    called EJB method,
    if my test code is run outside the weblogic server JVM. If the test code is
    run within the weblogic JVM (as a servlet), it works fine.
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception
    is:
    java.io.InvalidClassException: com.xxxx.model.RequestAggregate; Local class
    not compatible: stream classdesc serialVersionUID=8253439817277816629 local
    class serialVersionUID=-6336594865856381455
    I have verified that the class files are upto date in the test and weblogic
    VM.
    Adding a serialVersionUID to the class that fails to unmarshall makes it
    work. But I
    am curious to find out how the same class files in both the test and
    weblogic JVM can
    result in different SerialVersionUIDs.
    Any pointers about how and what information is used to compute
    these SerialVersionUIDs? Does the SerialVersionUID calculation use
    the dependent classes of the class that fails to unmarshall? Any help
    would be appreciated.
    thank you very much for your time,
    raj.

    Hi Raj,
    This exception is exactly what it is. You have version
    mismatch for the instances server and client has.
    It means the your verification is incorrect. For example
    old versions may be somehow coming up into the client's
    classpath.
    Make sure that client's classpath doesn't contain a different
    version of the class.
    Regards,
    Slava Imeshev
    "raj" <[email protected]> wrote in message
    news:3e9f0f6e$[email protected]..
    Hello:
    I get a SerialVersionUID mismatch, during argument unmarshalling for the
    called EJB method,
    if my test code is run outside the weblogic server JVM. If the test codeis
    run within the weblogic JVM (as a servlet), it works fine.
    java.rmi.UnmarshalException: error unmarshalling arguments; nestedexception
    is:
    java.io.InvalidClassException: com.xxxx.model.RequestAggregate; Localclass
    not compatible: stream classdesc serialVersionUID=8253439817277816629local
    class serialVersionUID=-6336594865856381455
    I have verified that the class files are upto date in the test andweblogic
    VM.
    Adding a serialVersionUID to the class that fails to unmarshall makes it
    work. But I
    am curious to find out how the same class files in both the test and
    weblogic JVM can
    result in different SerialVersionUIDs.
    Any pointers about how and what information is used to compute
    these SerialVersionUIDs? Does the SerialVersionUID calculation use
    the dependent classes of the class that fails to unmarshall? Any help
    would be appreciated.
    thank you very much for your time,
    raj.

  • Local class incompatible: stream classdesc serialVersionUID

    The following code is being executed from the configFile class:
    if(configFileIn != null)
    try
    ourConfigItemsAL = (ArrayList)alInObjectStream.readObject();
    catch(Exception e)
    configIsValid = false;
    System.out.println("Error: Can't read (readObject ourConfigItemsAL) from \"" + theFileName + "\". (" + e.toString() + ")");
    configItemsAL = theDefList;
    I get the following error when trying to run. It worked with an older version of the jre.
    Creating new NewConfigFile object.
    About to read configuration from "c:/Program Files/HearingRecorder/HearingRecorder.cfg" file.
    Error: Can't read (readObject ourConfigItemsAL) from "c:/Program Files/HearingRecorder/HearingRecorder.cfg". (java.io.InvalidClassException: javax.swing.JComponent; local class incompatible: stream classdesc serialVersionUID = -7908749299918704233, local class serialVersionUID = 7917968344860800289)
    java.lang.ExceptionInInitializerError
    Caused by: java.lang.NullPointerException
         at HearingRecorder.ConfigFile.readConfig(ConfigFile.java:150)
         at HearingRecorder.ConfigFile.<init>(ConfigFile.java:92)
         at HearingRecorder.HearingRecorder.<clinit>(HearingRecorder.java:4462)
    Exception in thread "main"

    The Java TutorialEssential Java Classes I/O: Object Serialization
    Lightweight persistence--the archival of an object for use in a later invocation of the same program.
    Serlization does not play nice between VM versions. It tells you this in the APIs for JComponent
    Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

  • SerialVersionUID problem with third party class

    Hello,
    One of our projects is using java 6 (that won't change). We need to use some third party APIs which is developped using java 5, and I guess some wild rmi implementation.
    If I try to use this api from a java 5 project, no problem.
    If I try to use it from java 6, I got this exception.
    Is there something I could try (workaround, something I can tell the api provider to fix, ...)?
    "C:\Program Files\Java\jdk1.6.0_01\bin\javaw.exe" -client -classpath D:\dev\TestAde\Project1\classes;D:\dev\TestAde\Project1\lib\ADEAde.jar;D:\dev\TestAde\Project1\lib\ADEConfig.jar;D:\dev\TestAde\Project1\lib\ADEJDom.jar;D:\dev\TestAde\Project1\lib\ADEMisc.jar;D:\dev\TestAde\Project1\lib\ADEStubs.jar project1.Test
    Exception in thread "main" java.lang.RuntimeException: Unable to connect to the server : java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
    java.io.InvalidClassException: sun.rmi.server.UnicastRef; local class incompatible: stream classdesc serialVersionUID = -9213327104222131866, local class serialVersionUID = 8258372400816541186
    at com.adesoft.config.ServerLocation.getRemoteConfig(Unknown Source)
    at com.adesoft.config.ConfigManager.getRemote(Unknown Source)
    at com.adesoft.config.ConfigManager.getProperty(Unknown Source)
    at com.adesoft.login.WebSessions.<init>(Unknown Source)
    at com.adesoft.login.WebSessions.getInstance(Unknown Source)
    at com.adesoft.beans.SessionBean.setLogin(Unknown Source)
    at project1.Test.main(Test.java:14)
    Process exited with exit code 1.

    The serialVersionUID of sun.rmi.server.UnicastRef in 1.5 is -9213327104222131866L. Strangely it isn't defined in the source code, just left to be calculated at runtime.
    I recommend you first search all your JAR files on both client and server, apart from the Java rt.jar of course, for classes in java.rmi.* and sun.rmi.*. If you find any class in these packages, or indeed in sun.* or java.*, complain loudly to the supplier, and try deleting them.
    If you don't find any such thing, I would then report this as a bug to Sun and I would also post it to the RMI-USERS mailing list where you will probably get a very rapid response.

  • Local class incompatible: different serialVersionUID

    Hi!
    I wrote an Object of type X to a file (in the server) and am sending the file to a client. This is done using:
    FileOutputStream fo = new FileOutputStream (filename);
    ObjectOutputStream so = new ObjectOutputStream (fo);
    so.writeObject(x); //x is of Object type X
    so.flush();
    so.close();
    fo.close();
    The file 'filename' is sent to the client and I read it as follows:
    FileInputStream in = new FileInputStream(filename);
    ObjectInputStream s = new ObjectInputStream(in);
    xobject = (X) x.readObject(); //xobject is of Object type X
    This is throwing an error as follows:
    java.util.Vector; local class incompatible:stream classdesc serialVersionUID = -2804478835259887871, local class serialVersionUID = -2767605614048989439
    Can anyone tell me what to do to be able to type cast the object and use it? I did go thro' some @serial documentation, but, couldn't understand it.
    Please help,
    Thanks,
    x86

    ...or, alternatively, maintain the X class in one package, the one where your server-side classes are compiled, say, and import it into the second, client side source code, which presumably lives in a separate package or this problem probably wouldn't have come up. The goal is never to have more than one copy of the compiled class file.
    You may have to modify your classpath.
    Hi!
    I wrote an Object of type X to a file (in theserver)
    and am sending the file to a client. This is done
    using:
    <snip>
    >
    This is throwing an error as follows:
    java.util.Vector; local class incompatible:stream
    classdesc serialVersionUID = -2804478835259887871,
    local class serialVersionUID = -2767605614048989439Hi
    try using one copy of the compiled class for the
    server
    and the client, I had this happen many times until I
    figured out
    the server compiled its version of the serialiable
    class and the client compiled its version of the
    serialiable class,
    then got class incompatable exceptions..among others
    easy way around this is to compile the code of botht
    he client and server, then copy the class code across
    to the client side
    Boris

Maybe you are looking for

  • Setting dynamic profile values in R3.0

    Hi Using the SDK can we set up profile values dynamically for use with Bursting. Currently it seems I have to define the profile values manually for each user and group or can use only the username, email or fullname for dynamic purposes. What i want

  • I have bought a second hand ipad 2 its locked to orange can this be unlocked

    i have bought a ipad 2 second hand its locked to orange can this be unlocked

  • How many sidlets on one page?

    I am trying to get one page to hold multiple sidlets, so that I can keep my movie small by having one page that pauses while the user "clicks on" each sidelet and read description of the features there. Problem is: I successfully added all the sidele

  • No sound when playing mpeg files

    I can't get quicktime to play sound when I try to play videos that are mpeg files. I already downloaded mpeg-2 playback as well as Perian 1.0 but it still won't play sound. Any suggestions?

  • Can't get 2 pdf's to merge

    Dell cmptr running Windows, Adobe Acrobat X running V. 10.1.13 Have had my HP Scanjet 5000 for about 4 yrs and all has been well when scanning documents and then being able to merge two or more together till lately. Now, whether I get a pdf thru emai