InvalidClassException ImageIcon.$AccessibleImageIcon class incompatible

Greetings,
I cannot seem to find a solution for this problem, so I am turning to you - your help is greatly appreciated.
Below is a snippet of some legacy code that has been deployed in an app running JRE 1.4.2.
class NodeImage implements Serializable {
    final static long serialVersionUID = 2606889903904458364L;
    public Dimension dim;
    public transient Image img;
    public ImageIcon ii; //VERY PROBLEMATIC NOW!!!!
    public String name;
    public String description;
  }Now, with the application having been modified and upgraded to run on JRE 1.5.0, old serialized objects can no longer be read into the above class, because the ImageIcon.$AccessibleImageIcon serialVersionUID has changed. The exception being thrown is as follows:
java.io.InvalidClassException: javax.swing.ImageIcon$AccessibleImageIcon;
local class incompatible: stream classdesc serialVersionUID = -3994512798706967451,
local class serialVersionUID = -1903458698681874148
        at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:519)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
        at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:468)
        at javax.swing.ImageIcon.readObject(ImageIcon.java:389)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        ...The object has no explicit readObject or writeObject methods.
I have tried a variety of things - e.g. writing a new readObject method, and using java.io.ObjectInputStream.GetField fields = in.readFields(); but I cannot seem to find a way to read the offending field without the exception being thrown and the rest of the read process aborted.
Is there ANY way around this?
I don't care if the end result makes the ImageIcon ii field null. But because this is just one object in a serialized hierarchy, I just want to be able to get the dim, name, and description attributes and then continue loading the remainder of the object hierarchy.
Thanks in advance for your help! Any insight would be great.
.

Your developers should have read the warning in the javadoc for javax.swing.ImageIcon before serializing ImageIcons across JDK versions.
You may have to use JDK 1.4 to read these streams and write them out again using something other than classes with this warning when they occur.
The only other thing I can suggest is a custom readObject method which doesn't call defaultReadObject() and instead picks apart the serialization protocol itself for the offending class(es), calling readObject() for all non-offending members.

Similar Messages

  • InvalidClassException: JComponent; local class incompatible - JVM Version?

    Iam having trouble deserializing some old objects.
    My object header is
    public class SoundMatrix extends AbstractTableModel implements Serializable
    So i happend to save some swing components :(
    Now i got the problem of deserializing them again. What can i do to recover the data?
    The serialVersionUID is the same, none has changed.
    java.io.InvalidClassException: javax.swing.JComponent; local class incompatible: stream classdesc serialVersionUID = -2514362798440941654, local class serialVersionUID = -1030230214076481435
         at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
         at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
         at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
         at javax.swing.event.EventListenerList.readObject(EventListenerList.java:255)
         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:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
         at dk.tigermedia.Prog.main(Prog.java:119)
    I guess its a JVM Versioning problem, the version may have changed over time, the application have been used.
    I know the problem is, that i have serialized Swing objects- the docs even warn against this. Great :)
    Can i see which version was used to make the files? Can take control over the deserializing process?
    Tryed overwriting the readObject - but it dont seem to get that far.
    Any help is much appreciated. Thanks.

    Update versions don't matter, just 1.3, 1.4, 1.5 etc.
    You don't need to recompile except backwards, e.g. if you're using JDK 1.3 you need binaries produced by 1.3 or with -target 1.3. But I'd advocate writing a new mini application for this conversion task, using 1.3 or whatever the JDK version actually was when the data was serialized.
    You also need to inform management about this debacle and the reasons for it. The warnings about serialization-incompatibility of Swing classes have been right there in the Javadoc since the beginning. No competent IT professional should have perpetrated this act. Make sure it doesn't happen again.

  • Java.io.InvalidClassException:local class incompatible?

    hello everyone:
    I deploy a J2EE application called A in a weblogic domain called A, it can run correctly;
    then I deploy another J2EE application called B, which is a new edition of A, in another weblogic domain called B, it can also run correctly;
    The two domains use the same server. I don't know whether this will cause problems like this.
    But the previous A can't run correctly and throw exceptions as follows in Java Console:
    java.io.InvalidClassException: com.longzhou.oa.docnet.dto.abstractdto.DnBaseRole; local class incompatible: stream classdesc serialVersionUID = 1264764439065723117, local class serialVersionUID = -6834466395328850197
         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.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.readArray(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 com.longzhou.oa.applet.util.EjbLocator.getInputStream(EjbLocator.java:18)
         at com.longzhou.oa.applet.DnIO.getDnAllByID(DnIO.java:63)
         at com.longzhou.oa.applet.DnIO.loadGraph(DnIO.java:33)
         at org.enhydra.jawe.DnDefine.loadDn(Unknown Source:185)
         at org.enhydra.jawe.AbstractEditor.<init>(Unknown Source:130)
         at org.enhydra.jawe.PackageEditor.<init>(PackageEditor.java:60)
         at org.enhydra.jawe.JaWE.init(JaWE.java:195)
         at org.enhydra.jawe.DnApplet.jbInit(DnApplet.java:67)
         at org.enhydra.jawe.DnApplet.init(DnApplet.java:54)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    java.lang.NullPointerException
         at com.longzhou.oa.applet.DnIO.getDnFromDto(DnIO.java:731)
         at com.longzhou.oa.applet.DnIO.loadGraph(DnIO.java:34)
         at org.enhydra.jawe.DnDefine.loadDn(Unknown Source:185)
         at org.enhydra.jawe.AbstractEditor.<init>(Unknown Source:130)
         at org.enhydra.jawe.PackageEditor.<init>(PackageEditor.java:60)
         at org.enhydra.jawe.JaWE.init(JaWE.java:195)
         at org.enhydra.jawe.DnApplet.jbInit(DnApplet.java:67)
         at org.enhydra.jawe.DnApplet.init(DnApplet.java:54)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.lang.Object
         at java.io.ObjectInputStream.readObject0(Unknown Source)
         at java.io.ObjectInputStream.readObject(Unknown Source)
         at com.longzhou.oa.applet.util.EjbLocator.getInputStream(EjbLocator.java:18)
         at com.longzhou.oa.applet.InitModel.initEmpGroupList(InitModel.java:353)
         at org.enhydra.jawe.DnDefine._$1(Unknown Source:241)
         at org.enhydra.jawe.DnDefine.loadDn(Unknown Source:186)
         at org.enhydra.jawe.AbstractEditor.<init>(Unknown Source:130)
         at org.enhydra.jawe.PackageEditor.<init>(PackageEditor.java:60)
         at org.enhydra.jawe.JaWE.init(JaWE.java:195)
         at org.enhydra.jawe.DnApplet.jbInit(DnApplet.java:67)
         at org.enhydra.jawe.DnApplet.init(DnApplet.java:54)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.NotSerializableException: java.lang.Object
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.writeObject(Unknown Source)
         at com.longzhou.oa.util.EgovServlet.service(EgovServlet.java:332)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6981)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
         at java.lang.Thread.startThreadFromVM(Unknown Source)
    java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.lang.Object
         at java.io.ObjectInputStream.readObject0(Unknown Source)
         at java.io.ObjectInputStream.readObject(Unknown Source)
         at com.longzhou.oa.applet.util.EjbLocator.getInputStream(EjbLocator.java:18)
         at com.longzhou.oa.applet.InitModel.initSysRoleList(InitModel.java:371)
         at org.enhydra.jawe.DnDefine._$1(Unknown Source:242)
         at org.enhydra.jawe.DnDefine.loadDn(Unknown Source:186)
         at org.enhydra.jawe.AbstractEditor.<init>(Unknown Source:130)
         at org.enhydra.jawe.PackageEditor.<init>(PackageEditor.java:60)
         at org.enhydra.jawe.JaWE.init(JaWE.java:195)
         at org.enhydra.jawe.DnApplet.jbInit(DnApplet.java:67)
         at org.enhydra.jawe.DnApplet.init(DnApplet.java:54)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.NotSerializableException: java.lang.Object
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.writeObject(Unknown Source)
         at com.longzhou.oa.util.EgovServlet.service(EgovServlet.java:332)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6981)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
         at java.lang.Thread.startThreadFromVM(Unknown Source)
    Can anyone tell me the reason? Thanks

    "local class incompatible" error is due to the retrieving of serialized object, which might be dumping from memory to somewhere like database, file etc., that is of different edition of the class. Maybe an object A of AClass was stored in a database and lately the AClass changed to a new edition, let's call it A'Class, and they have something different, especially the serialVersionUID field. When the object A is retrieved from the database, which should be compatible with A'Class (be ware of that A'Class and AClass has the same name but of different edition), unfortunately, they don't, the error mentioned above occurs.
    So, I guess that although the app A and B uses different domain, if they uses the same database to store and retrieve something (here may refers to objects) of different edition and are run one after another, the compatible issues are going to occur.
    Separating app A from B as much as possible is not a good solution, but you could have a try.
    Hoping helpful, good luck!

  • 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 ?

  • Ava.io.InvalidClassException: local class incompatible: stream classdesc

    Hi,
    When I am testing a scnerio in my application, I am getting the following error. When I am trying to do again, I am not getting this error. Basically when first time serializable object creation, I am getting this error I guess. Pls reply as its really disturbs our application in Production.
    22 Apr 2005 14:27:12,442 ERROR [service-j2ee] model.TopsFileManager - java.io.InvalidClassException: com.gepower.gees.tops.data.JobCtxtMgr; local class incompatible: stream classdesc serialVersionUID = 7011266017804180214, local class serialVersionUID = 1299119170608910687
    java.io.InvalidClassException: com.gepower.gees.tops.data.JobCtxtMgr; local class incompatible: stream classdesc serialVersionUID = 7011266017804180214, local class serialVersionUID = 1299119170608910687
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:463)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
    at com.gepower.gees.tops.model.TopsFileManager.getValue(TopsFileManager.java:159)
    at com.gepower.gees.tops.control.PlanJobAssocCtrl.process(PlanJobAssocCtrl.java:181)
    at com.gepower.gees.tops.control.LeafCommand.perform(LeafCommand.java:93)
    at com.ge.dialect.cb.DefaultController.processInteraction(DefaultController.java:790)
    at com.ge.dialect.cb.DefaultController.handleInteraction(DefaultController.java:607)
    at com.ge.dialect.cb.DefaultController.service(DefaultController.java:490)
    at com.ge.casper.servlet.CasperServlet.service(CasperServlet.java:231)
    at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:720)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:309)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
    at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
    22 Apr 2005 14:27:12,445 ERROR [service-j2ee] control.ProcessJobCtrl - com.gepower.gees.tops.data.JobCtxtMgr; local class incompatible: stream classdesc serialVersionUID = 7011266017804180214, local class serialVersionUID = 1299119170608910687
    Thanks in advance

    Hello
    I am using Netbeans5.5, JBoss 4.0.4 with hibernate3. I have a simple Entity bean (UserProfile), which i mapped from the database table.
    In the session bean, i am using EntityManager to find my Entity bean i.e. UserProfile. But i am getting the following exception:
    java.rmi.MarshalException: Failed to communicate.  Problem during marshalling/unmarshalling; nested exception is:
            java.io.InvalidClassException: org.hibernate.collection.PersistentBag; local class incompatible: stream classdesc serialVersionUID = -992182677146982163, local class serialVersionUID = 2819117614876030537
            at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:306)
            at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
            at org.jboss.remoting.Client.invoke(Client.java:525)
            at org.jboss.remoting.Client.invoke(Client.java:488)
            at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:78)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            at org.jboss.ejb3.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:133)
            at $Proxy1.findUser(Unknown Source)
            at anapro.Main.main(Main.java:34)
    Caused by: java.io.InvalidClassException: org.hibernate.collection.PersistentBag; local class incompatible: stream classdesc serialVersionUID = -992182677146982163, local class serialVersionUID = 2819117614876030537
            at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:519)
            at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
            at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
            at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
            at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
            at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:122)
            at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
            at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
            at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
            at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
            at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
            at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:279)
            ... 14 moreSince netbeans creates an EJB module and a client module, I have added hibernate-entitymanager.jar to the class path of both the client and ejb module but this exception exists. can anyone please help me in this?
    thanks

  • Oracle.jbo.domain.Number; local class incompatible

    Hi Forum,
    Development Tool     : Jdeveloper 9.0.4 (part of Oracle 10g Suite)
    Target Application Summary:
    A simple application which displays the content of a database table and allows it to be modified both through a web interface as well as a Swing standalone client.
    A Workspace having three projects:
    1) A Business layer defined by using BC4J(Business Components For Java) provided with Jdeveloper 10g.
    2) A Swing/JClient application for BC4J which accesses the BCJ4 layer using a Business component client data model.
    3)A JSP application using JSP for business components which accesses the BC4j layer
    Target Deployment:
    1) Light-weight swing interface at machine 1
    2) Business components and JSP part in an application server on Machine 2
    3) Oracle DB on Machine3
    Problem Statement
    We deployed the BC4J Middle tier on OC4J standalone as a session bean. Then the client jar was deployed as a remote application(using Swing/JClient for business componments), the following error comes:
    (oracle.jbo.PiggybackException) JBO-28300: Piggyback read error
    ----- LEVEL 1: DETAIL 0 -----
    (java.io.InvalidClassException) oracle.jbo.domain.Number; local class incompatible: stream classdesc serialVersionUID = -6507359405709672486, local class serialVersionUID = -592084144037230518
    Can the forum help me with the problem (i am using the library BC4JOracleDomains which has oracle.jbo.domain.Number class)
    Thanking you in advance.

    Firstly, good job on describing your problem/situation. Some people just don't bother to be verbose.
    Secondly, I have to note that I don't do any development in this way so I have no 1st hand experience with this excpetion. But, it appears as though you are using different versions of the jar files (which in turn contain different versions of the classes). Maybe you should take a look at that?

  • Help!:  local class incompatible exception

    Hi!, im new in the ejb tech, I'm using jboss 3.2.3, windows 2000, j2ee 1.4 and jdk 1.4.1.
    I already deploy the ejb in the app server, but at the Context.lookup statement from the client i get a local class incompatible exception!!, could anyone help me with this??? the client and the ejb are running in different machines, but the classes are the same ( I map the network drive and put it in my classpath to ensure im using the same classes with the same serial uid).
    Thanks a lot!!!
    The complete Stack trace is
    javax.naming.CommunicationException. Root exception is java.io.InvalidClassException: org.jboss.proxy.ejb.GenericEJBInterceptor; local class incompatible: stream classdesc serialVersionUID = 3844706474734439975, local class serialVersionUID = 4582256576523491346
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:459)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
    at org.jboss.proxy.ClientContainer.readExternal(ClientContainer.java:104)

    Sorry, i already found the problem!!! . I was running the client within the forte 4 ee ide, and it seems that forte assigns the objects their own serial uid. When I execute the client from a terminal, it executes ok =)

  • Oracle.jdbc.pool.OracleDataSource; local class incompatible

    I want to place a DataSource in a InitialContext with the following code
    public void getEnvironment() throws Exception{ try{ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); /*System.setProperty(Context.PROVIDER_URL, "t3://127.0.0.1:7001"); System.setProperty(Context.SECURITY_PRINCIPAL, "weblogic"); System.setProperty(Context.SECURITY_CREDENTIALS, "password");*/ InitialContext ic = new InitialContext(); ic.createSubcontext("java:"); ic.createSubcontext("java:/comp"); ic.createSubcontext("java:/comp/env"); ic.createSubcontext("java:/comp/env/jdbc"); // Construcvt Datasource OracleConnectionPoolDataSource ds = new OracleConnectionPoolDataSource(); ds.setURL("jdbc:oracle:thin:@cdcehr29:14985"); ds.setUser("user"); ds.setPassword("pwd"); //Connection conn = ds.getConnection(); ic.bind("java:/comp/env/jdbc/test", ds); System.out.println("see?"); Context envIc = (Context) ic.lookup("java:/comp/env"); envIc.bind("THIS_SERVICE_CD", ""); envIc.bind("THIS_SERVICE_VER", ""); envIc.bind("SERVICE_DATA_SOURCE_JNDI", "jdbc/test"); envIc.bind("ALS_PROJECT_CD", ""); envIc.bind("ALS_SYSTEM_CD", ""); envIc.bind("EHR_CONFIG_DATA_SOURCE_JNDI", ""); envIc.bind("SGR_PATH", ""); envIc.bind("AUDIT_TABLE_NAME", ""); envIc.bind("DEBUG_TABLE_NAME", ""); }catch(NamingException ex){ ex.printStackTrace(); }catch(Exception ex){ ex.printStackTrace(); } }
    but the following error is shown (but not catch in catch block, very strange)
    >
    <Jun 26, 2012 6:17:02 PM CST> <Error> <RJVM> <BEA-000503> <Incoming message header or abbreviation processing failed
    java.io.InvalidClassException: oracle.jdbc.pool.OracleDataSource; local class incompatible: stream classdesc serialVersionUID = 8680830911645568991, local class serialVersionUID = 3349652938965166731
    java.io.InvalidClassException: oracle.jdbc.pool.OracleDataSource; local class incompatible: stream classdesc serialVersionUID = 8680830911645568991, local class serialVersionUID = 3349652938965166731
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1316)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    Truncated. see log file for complete stacktrace
    >
    what is the problem come from?

    >
    but the following error is shown (but not catch in catch block, very strange)
    >
    <Jun 26, 2012 6:17:02 PM CST> <Error> <RJVM> <BEA-000503> <Incoming message header or abbreviation processing failed
    java.io.InvalidClassException: oracle.jdbc.pool.OracleDataSource; local class incompatible: stream classdesc serialVersionUID = 8680830911645568991, local class serialVersionUID = 3349652938965166731
    java.io.InvalidClassException: oracle.jdbc.pool.OracleDataSource; local class incompatible: stream classdesc serialVersionUID = 8680830911645568991, local class serialVersionUID = 3349652938965166731
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1316)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    Truncated. see log file for complete stacktrace
    what is the problem come from?
    >
    You didn't post the part of the stacktrace that shows the line number that the problem occured on. (Truncated. see log file for complete stacktrace)
    Are you sure the problem occured in the code you posted? If so did this line execute and print on the console?
    System.out.println("see?");That error can occur when the code used to deserialize an object uses a different version of the class than the version it was serialized with. The code you posted doesn't shown anything that appears to do any deserialization.
    Have their been any changes to the environment lately? Upgrades to Java version, WebLogic or the JDBC driver?

  • 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.

  • 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

  • Invalid Class Exception problem

    Hi whenever i try to run this method from a different class to the one it is declared in it throws invalid class exception, (in its error it says the class this method is written in is the problem) yet when i run it from its own class in a temporary main it works fine, perhaps someone can see the problem in the method code. All its doing is reading from a few different txt files, deserializing the objects and putting them into arraylists for future access.
    public void readCourseData()
              CourseArrayLengths cal;
              try
                   FileInputStream fis = new FileInputStream("arraylengths.txt");
                   ObjectInputStream ois = new ObjectInputStream(fis);
                   cal = ((CourseArrayLengths) ois.readObject());     
                   ois.close();
                   FileInputStream fis1 = new FileInputStream("units.txt");
                   ObjectInputStream ois1 = new ObjectInputStream(fis1);
                   for(int i=0;i<cal.getUnitArrayLength();i++)
                        units.add((Unit) ois1.readObject());
                   ois1.close();
                   FileInputStream fis2 = new FileInputStream("sections.txt");
                   ObjectInputStream ois2 = new ObjectInputStream(fis2);
                   for(int i=0;i<cal.getSectionArrayLength();i++)
                        sections.add((Section) ois2.readObject());
                   ois2.close();
                   FileInputStream fis3 = new FileInputStream("files.txt");
                   ObjectInputStream ois3 = new ObjectInputStream(fis3);
                   for(int i=0;i<cal.getFileArrayLength();i++)
                        files.add((Filetype) ois3.readObject());
                   ois3.close();
              catch(FileNotFoundException exception)
              System.out.println("The File was not found");
              catch(IOException exception)
              System.out.println(exception);
              catch(ClassNotFoundException exception)
              System.out.println(exception);
         }

    import java.util.ArrayList;
    import java.io.*;
    import javax.swing.*;
    public class Unit implements Serializable
    ArrayList units = new ArrayList();
    ArrayList sections = new ArrayList();
    ArrayList files = new ArrayList();
    String unitName;
    int sStart=0,sEnd=0,sIndex=0,fIndex=0,subIndex=0;
         public Unit(String unitNamec,int sStartc,int sEndc)
              unitName = unitNamec;
              sStart = sStartc;
              sEnd = sEndc;
         public Unit()
         public String getUnitName()
              return unitName;
         public Unit getUnit(int i)
              return (Unit)units.get(i);
         public Section getSection(int i)
              return (Section)sections.get(i);
         public ArrayList getUnitArray()
              return units;
         public int getSectionStart()
              return sStart;
         public int getSectionEnd()
              return sEnd;
         public void setSectionStart(int i)
              sStart = i;
         public void setSectionEnd(int i)
              sEnd = i;
         public void addUnit(String uName)
              units.add(new Unit(uName,sections.size(),sIndex));
              sIndex++;
         public void addSection(String sName,Unit u)
              //problem lies with files.size()
              sections.add(new Section(sName,files.size(),files.size()));
              u.setSectionEnd(u.getSectionEnd()+1);
              //fIndex++;
         public void addFile(String fName,File fPath,Section s)
              files.add(new Filetype(fName,fPath));
              s.setFileEnd(s.getFileEnd()+1);
         public void display(Unit u)
              System.out.println(u.getUnitName());
              for(int i=u.getSectionStart();i<u.getSectionEnd();i++)
                   System.out.println(((Section)sections.get(i)).getSectName());
                   for(int j=((Section)(sections.get(i))).getFileStart();j<((Section)(sections.get(i))).getFileEnd();j++)
                        System.out.println(((Filetype)files.get(j)).getFileName());
         public void writeCourseData()
         //writes 3 arrays to 3 different files
    try
    FileOutputStream fos = new FileOutputStream("units.txt");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
         for(int i=0;i<units.size();i++)
         oos.writeObject((Unit)units.get(i));
         oos.close();
    catch (Exception e)
    System.err.println ("Error writing to file");
    try
    FileOutputStream fos = new FileOutputStream("sections.txt");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
         for(int i=0;i<sections.size();i++)
         oos.writeObject((Section)sections.get(i));
         oos.close();
    catch (Exception e)
    System.err.println ("Error writing to file");
    try
    FileOutputStream fos = new FileOutputStream("files.txt");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
         for(int i=0;i<files.size();i++)
         oos.writeObject((Filetype)files.get(i));
         oos.close();
    catch (Exception e)
    System.err.println ("Error writing to file");
    try
    FileOutputStream fos = new FileOutputStream("arraylengths.txt");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
         oos.writeObject(new CourseArrayLengths(units.size(),sections.size(),files.size()));
         oos.close();
    catch (Exception e)
    System.err.println ("Error writing to file");
         public void readCourseData()
              CourseArrayLengths cal;
              try
                   FileInputStream fis = new FileInputStream("arraylengths.txt");
                   ObjectInputStream ois = new ObjectInputStream(fis);
                   cal = ((CourseArrayLengths) ois.readObject());     
                   ois.close();
                   FileInputStream fis1 = new FileInputStream("units.txt");
                   ObjectInputStream ois1 = new ObjectInputStream(fis1);
                   for(int i=0;i<cal.getUnitArrayLength();i++)
                        units.add((Unit) ois1.readObject());
                   ois1.close();
                   FileInputStream fis2 = new FileInputStream("sections.txt");
                   ObjectInputStream ois2 = new ObjectInputStream(fis2);
                   for(int i=0;i<cal.getSectionArrayLength();i++)
                        sections.add((Section) ois2.readObject());
                   ois2.close();
                   FileInputStream fis3 = new FileInputStream("files.txt");
                   ObjectInputStream ois3 = new ObjectInputStream(fis3);
                   for(int i=0;i<cal.getFileArrayLength();i++)
                        files.add((Filetype) ois3.readObject());
                   ois3.close();
              catch(FileNotFoundException exception)
              System.out.println("The File was not found");
              catch(IOException exception)
              System.out.println(exception);
              catch(ClassNotFoundException exception)
              System.out.println(exception);
         /*public static void main(String args[])
              Unit u1 = new Unit();
              u1.addUnit("Cmps2a22");
              u1.addSection("Section1",u1.getUnit(0));
              //u1.addSubSection("Subsect1",u1.getSection(0));
              u1.addFile("File1",null,u1.getSection(0));
              u1.addFile("File2",null,u1.getSection(0));
              u1.addSection("Section2",u1.getUnit(0));
              u1.addFile("NF",null,u1.getSection(1));
              u1.addFile("NF2",null,u1.getSection(1));
              u1.addFile("NF3",null,u1.getSection(1));
              u1.addSection("Section3",u1.getUnit(0));
              u1.addFile("NF",null,u1.getSection(2));
              u1.addFile("NF2",null,u1.getSection(2));
              u1.addFile("NF4",null,u1.getSection(2));
              u1.display(u1.getUnit(0));
              u1.writeCourseData();
              u1.readCourseData();
              u1.display(u1.getUnit(0));
    import java.util.ArrayList;
    import java.io.*;
    public class Section implements Serializable
    private String sectName,subSectName;
    private int fpStart=0,fpEnd=0,subSectStart=0,subSectEnd=0;
    private Section s;
    private boolean sub;
         public Section(String sectNamec,int fpStartc,int fpEndc,int subSectStartc,int subSectEndc,Section sc,boolean subc)
              sectName = sectNamec;
              fpStart = fpStartc;
              fpEnd = fpEndc;
              subSectStart = subSectStartc;
              subSectEnd = subSectEndc;
              s = sc;
              sub = subc;
         public Section(String sectNamec,int fpStartc,int fpEndc)
              sectName = sectNamec;
              fpStart = fpStartc;
              fpEnd = fpEndc;
         public Section getParent()
              return s;
         public boolean isSub()
              return sub;
         public String getSubName()
              return subSectName;
         public int getSubStart()
              return subSectStart;
         public int getSubEnd()
              return subSectEnd;
         public void setSubStart(int i)
              subSectStart = i;
         public void setSubEnd(int i)
              subSectEnd = i;
         public int getFileStart()
              return fpStart;
         public int getFileEnd()
              return fpEnd;
         public String getSectName()
              return sectName;
         public void setFileStart(int i)
              fpStart = i;
         public void setFileEnd(int i)
              fpEnd = i;
         public void addSection(String sectName)
         /*public static void main(String args[])
    import java.io.*;
    public class Filetype implements Serializable
         private String name;
         private File filepath;
         public Filetype(String namec, File filepathc)
              name = namec;
              filepath = filepathc;
         public String getFileName()
              return name;
         public File getFilepath()
              return filepath;
    import java.io.*;
    public class CourseArrayLengths implements Serializable
    private int ul,sl,fl;
         public CourseArrayLengths(int ulc,int slc,int flc)
              ul = ulc;
              sl = slc;
              fl = flc;
         public int getUnitArrayLength()
              return ul;
         public int getSectionArrayLength()
              return sl;
         public int getFileArrayLength()
              return fl;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.ArrayList;
    import java.io.*;
    public class OrganiserGui implements ActionListener
    int width,height;
    JFrame frame;
         public OrganiserGui()
              width = 600;
              height = 500;
         public void runGui()
              //Frame sizes and location
              frame = new JFrame("StudentOrganiser V1.0");
    frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
              frame.setSize(width,height);
              frame.setLocation(60,60);
              JMenuBar menuBar = new JMenuBar();
              //File menu
              JMenu fileMenu = new JMenu("File");
              menuBar.add(fileMenu);
              fileMenu.addSeparator();
              JMenu addSubMenu = new JMenu("Add");
              fileMenu.add(addSubMenu);
              JMenuItem cwk = new JMenuItem("Coursework assignment");
              addSubMenu.add(cwk);
              JMenuItem lecture = new JMenuItem("Lecture");
              lecture.addActionListener(this);
              addSubMenu.add(lecture);
              JMenuItem seminar = new JMenuItem("Seminar sheet");
              addSubMenu.add(seminar);
              //Calendar menu
              JMenu calendarMenu = new JMenu("Calendar");
              menuBar.add(calendarMenu);
              calendarMenu.addSeparator();
              JMenu calendarSubMenu = new JMenu("Edit Calendar");
              calendarMenu.add(calendarSubMenu);
              JMenuItem eventa = new JMenuItem("Add/Remove Event");
              eventa.addActionListener(this);
              calendarSubMenu.add(eventa);
              JMenuItem calClear = new JMenuItem("Clear Calendar");
              calClear.addActionListener(this);
              calendarSubMenu.add(calClear);
              JMenu calendarSubMenuView = new JMenu("View");
              calendarMenu.add(calendarSubMenuView);
              JMenuItem year = new JMenuItem("By Year");
              year.addActionListener(this);
              calendarSubMenuView.add(year);
              JMenuItem month = new JMenuItem("By Month");
              month.addActionListener(this);          
              calendarSubMenuView.add(month);
              JMenuItem week = new JMenuItem("By Week");
              week.addActionListener(this);
              calendarSubMenuView.add(week);
              //Timetable menu
              JMenu timetableMenu = new JMenu("Timetable");
              menuBar.add(timetableMenu);
              timetableMenu.addSeparator();
              JMenu stimetableSubMenu = new JMenu("Social Timetable");
              timetableMenu.add(stimetableSubMenu);
              JMenu ltimetableSubMenu = new JMenu("Lecture Timetable");
              timetableMenu.add(ltimetableSubMenu);
              frame.setJMenuBar(menuBar);
    frame.setVisible(true);
         public void actionPerformed(ActionEvent e)
              JMenuItem source = (JMenuItem)(e.getSource());
              System.out.println(source.getText());     
              Calendar c = new Calendar();
              if(source.getText().equalsIgnoreCase("By Year"))
                   System.out.println("INSIDE");
                   c.buildArray();
                   c.calendarByYear(Calendar.calendarArray);     
              if(source.getText().equalsIgnoreCase("Add/Remove Event"))
                   c.eventInput();
              if(source.getText().equalsIgnoreCase("clear calendar"))
                   c.buildYear();
                   c.writeEvent(Calendar.calendarArray);
                   c.buildArray();
              if(source.getText().equalsIgnoreCase("lecture"))
                   System.out.println("Nearly working");
                   //JFileChooser jf = new JFileChooser();
                   //jf.showOpenDialog(frame);
                   FileManager fm = new FileManager();
                   //choose unit to add file to
                   JOptionPane unitOption = new JOptionPane();
                   Unit u = new Unit();
                   u.readCourseData();
                   //u.display(u.getUnit(0));
                   System.out.println((u.getUnit(0)).getUnitName());
                   String[] unitNames = new String[u.getUnitArray().size()];
                   for(int i=0;i<unitNames.length;i++)
                        //unitNames[i] = (((Unit)u.getUnitArray().get(i)).getUnitName());
                        //System.out.println(unitNames);
                        System.out.println((u.getUnit(i)).getUnitName());
                   //unitOption.showInputDialog("Select Unit to add lecture to",unitNames);
                   //needs to select where to store it
                   //fm.openFile(jf.getSelectedFile());
         public static void main(String args[])
              OrganiserGui gui = new OrganiserGui();
              gui.runGui();
    java.io.invalidclassexception: Unit; local class incompatible: stream classdesc serialversionUID = 3355176005651395533, local class serialversionUID = 307309993874795880

  • Weird error message; please help!!!

    java.io.InvalidClassException: DrawingCanvas; local class incompatible: stream classdesc serialVersionUID = -8511311069504091406, local class serialVersionUID = 90-4285921088278508
    that was the error I got and I have no idea what it means. DrawingCanvas is a class I wrote and I don't think there is anything wrong with it but I don't know what the error means so can someone please help me.

    http://developer.java.sun.com/developer/technicalArticles/Programming/serialization/
    Check the section on version control

  • NIO and object serialization

    I try to use the new IO API to implement a non-blocking multi-threaded server that communicates with client applications by exchanging serialized objects. I started from the code in the JavaWorld article at http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin.html .
    With the new features of J2SDK 1.4.0, you don't have to create a separate thread per connected client. That is a big improvement.
    But when I read an object with ObjectInputStream, I get a java.nio.channels.IllegalBlockingModeException.
    Has anybody successfully implemented such a server since the release of the new io API?
    Thanks.
    Jean-Robert

    Hi,
    I tried to decode it and reconstruct the object as follows:
    buffer.flip();
    // Decode buffer
    decoder.decode(buffer, charBuffer, false);
    // Display
    charBuffer.flip();
    String str = charBuffer.toString();
    try
         ByteArrayInputStream bis = new ByteArrayInputStream(str.getBytes());
         ObjectInputStream ois = new ObjectInputStream(bis);
         Object obj = ois.readObject();
         if (obj != null)
         System.out.println(obj.getClass().getName());
         System.out.println("Construction successful");
    catch (Exception e)
         e.printStackTrace();
    I think it is constructing the object. But it gave me the following exception:
    java.io.InvalidClassException: MessageValueObject; local class incompatible: stream classdesc serialVersionUID = -1062950779601993928, local class serialVersionUID = -1038743931604855240
         at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:454)
         at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1511)
         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1425)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1616)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)
         at com.csxwt.zodiac.client.common.NIOPushletClient.run(NIOPushletClient.java:254)
         at java.lang.Thread.run(Thread.java:536)
    Whe I compared the bytes of returned object with the actual object I noticed that two bytes were different from the orignal. They were replaced with '?' (byte code 063) in the reconstructed byte stream.
    If anybody have a clue please help me too

  • 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.

  • Giving a Class an ImageIcon

    hello all,
    i am a relative beginner to java and am having a small bit of difficulty in a small venture, and was wondering if someone could help.
    I am in the middle of creating a top-down tile-based turn-based engine. I am currently at very early stages.
    - i have a class called "tile". This only contains code for two ints (TerrainType and MovementCost).
    - I make a grid of references, and then apply a whatever.tile to each reference, using an array, which defines the map.
    - The trouble is at the nestedloop, where i cannot apply an "ImageIcon" to class.tile.
    How should i change my code? By the way, this is my 2nd version of this - The first version, used jLabels instead of class.tile, and it worked fine. However i couldnt figure out how to apply attributes to it.
    *****CODE******
    ImageIcon block = new ImageIcon("block.gif");
    ImageIcon grass = new ImageIcon("grass.gif");
    tile t0 = new tile();
    tile t1 = new tile();
    tile t2 = new tile();
    tile t3 = new tile();
    ArrayList tt = new ArrayList();
    tt.add("0");
    tt.add("0");
    tt.add("0");
    tt.add("1");
    tt.add("x");
    int max_rows = 2;
    int max_cols = 2;
    int x = 0;
    tile[][] grid = new tile[max_rows][max_cols];
    grid[0][0] = t0;
    grid[0][1] = t1;
    grid[1][0] = t2;
    grid[1][1] = t3;
    for (int r = 0; r < max_rows; r++) {
    for (int c = 0; c < max_cols; c++) {
    if (tt.get(0).equals("0")){
    grid[r][c].setIcon(grass); <<<<error
    tt.remove(0);}
    else if (tt.get(0).equals("1")){
    grid[r][c].setIcon(block); <<<<error
    tt.remove(0);}
    **********class code*****
    package mapalpha;
    public class tile {
    int TerrainType;
    int MovementCost;
    public tile() {
    }

    To add an 'attribute' to a JLabel: since JLabel extends from JComponent you can use the 'putClientProperty' and the 'getClientProperty' methods to store/retrieve attribute-type information in the component. See the method detail section for each method in the JComponent api.
    On your current design: you can put anything you want in your custom Tile class - ImageIcon, JLabel, JPanel, an image...
    class Tile
        int terrainType, movementCost;
        BufferedImage image;
        ImageIcon icon;
        JLabel label;
        public Tile(args for instantiation if you like...)
        protected void setIcon(ImageIcon icon)
            this.icon = icon;
            // other activity if you like
    }If you want an image/graphics component you could have Tile extend JPanel or JLabel. Then you could override the 'paintComponent' method in JPanel and draw your image/graphics. If extending JLabel simply call 'setIcon' which will be a JLabel method - not the same as in the pseudo code above (which is a 'set' method for the Tile class).

Maybe you are looking for