File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes RMI InvalidClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI InvalidClassCastException" Watch "RMI InvalidClassCastException" New topic
Author

RMI InvalidClassCastException

Michael Vargenstien
Ranch Hand

Joined: Jan 27, 2007
Posts: 61
Hello,

I am using a class that has an RMI call in it. When I attempt to debug everything executes as expected until the object is returned. When the contract object returns, I recieve an error like this:

java.io.InvalidClassException: com.dn.lca.dataobjects.Contract; local class incompatible: stream classdesc serialVersionUID = -7475071795924394977, local class serialVersionUID = -3554625892121869643>
org.springframework.remoting.RemoteConnectFailureException: Cannot connect to remote service [rmi://localhost:1199/RemoteService]; nested exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.InvalidClassException: com.dn.lca.dataobjects.Contract; local class incompatible: stream classdesc serialVersionUID = -7475071795924394977, local class serialVersionUID = -3554625892121869643
Caused by:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.InvalidClassException: com.rn.mca.dataobjects.Contract; local class incompatible: stream classdesc serialVersionUID = -7475071795924394977, local class serialVersionUID = -3554625892121869643
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at org.springframework.remoting.rmi.RmiInvocationWrapper_Stub.invoke(Unknown Source)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:400)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:344)
at org.springframework.remoting.rmi.RmiClientInterceptor.invoke(RmiClientInterceptor.java:259)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
at $Proxy4.generateRenewalContract(Unknown Source)
at com.rn.mca.client.service.RenewalGenServiceImpl.generateRenewalContract(RenewalGenServiceImpl.java:52)
at com.rn.mca.ui.wizard.WizardController$7.run(WizardController.java:610)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.InvalidClassException: com.rn.mca.dataobjects.Contract; local class incompatible: stream classdesc serialVersionUID = -7475071795924394977, local class serialVersionUID = -3554625892121869643
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.readObject(Unknown Source)
at sun.rmi.server.UnicastRef.unmarshalValue(Unknown Source)
... 11 more

I have checked my jar files and they all have the same time stamp. I have used a decompiler to check the compiled classes as well with the same findings. I am currently using eclipse europa to debug this issue and haven't been able to come up with anything that makes much sense. I have heard about the serialver tool but I have been having alot of trouble using it. Are there any other alternatives that provide a entry level guy a more faster way to determine what versions the compiler is seeing?

Thanks for your help!!
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Do you have this class somewhere else in either the server/client classpath?
It may be that one of them is picking an older version of the class from the classpath.
It looks pretty clear that either the server or the client has an incompatible class version.
If both the client and server code is yours and you can afford to do a clean build of all the jars then that will be the best way of getting out of all this!
I would suggest cleaning up the classpath also as in remove the jars that you do not require.


apigee, a better way to API!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI InvalidClassCastException
 
Similar Threads
CommunicationException
Remote Object having JFrame referrence
local class incompatible error
Problem with jasper report -loading stream
jasper reports -Plz help me out