• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 484
  • Last Modified:

RMI object passing problem

hi experts,
 
   in my rmi application, i want to sent server CLASS_A type objects and i designed server interface that way, then at the client side i wrote objects extending CLASS_A so that they would have common methods and be recognized by the rmi server. The problem is there is sometihng wrong and i get the following exception:


java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
      java.lang.ClassNotFoundException: client.testobject (no security manager: RMI class loader disabled)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:325)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      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 java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:179)
      at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
      at $Proxy0.pass(Unknown Source)
      at client.clientTest.Connect(clientTest.java:35)
      at client.clientTest.<init>(clientTest.java:26)
      at client.Main.main(Main.java:23)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
      java.lang.ClassNotFoundException: client.testProc (no security manager: RMI class loader disabled)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:285)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: client.testProc (no security manager: RMI class loader disabled)
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:371)
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
      at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
      at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
      at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1538)
      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.readObject(ObjectInputStream.java:339)
      at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:290)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:279)
      ... 6 more


I don't know what is wrong i spent hour but i couldn't figure out the problem.

Does any body can post some usefull code doing the job i said above, i need a base class for sending between nodes and ii want to have other classes extending base class and be able to passed to an rmi server.

thanks
0
sunny012097
Asked:
sunny012097
1 Solution
 
kiranhkCommented:
you need to have the security Manager set for your client..

or use this while starting your RMI server

java -Djava.security.manager -Djava.security.policy=policy-file MyClass



http://www.ccs.neu.edu/home/kenb/com3337/rmi_tut.html
0
 
sunny012097Author Commented:
 
  now getting exceptions again. Here is stack:



java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
      java.io.InvalidClassException: common.Process; local class incompatible: stream classdesc serialVersionUID = -7788712377034963467, local class serialVersionUID = 2506602152668479765
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:325)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      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 java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:179)
      at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
      at $Proxy0.submit(Unknown Source)
      at kernel.applications.NetworkManager.run(NetworkManager.java:80)
      at java.lang.Thread.run(Thread.java:595)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
      java.io.InvalidClassException: common.Process; local class incompatible: stream classdesc serialVersionUID = -7788712377034963467, local class serialVersionUID = 2506602152668479765
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:282)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      ... 1 more
Caused by: java.io.InvalidClassException: common.Process; local class incompatible: stream classdesc serialVersionUID = -7788712377034963467, local class serialVersionUID = 2506602152668479765
      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.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.readObject(ObjectInputStream.java:339)
      at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:290)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:279)
      ... 6 more
0
 
CodingExpertsCommented:
Does your CLASS_A class implements Serializable interface ???

-CE
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CodingExpertsCommented:
I am sorry... please ignore my previous post ...
0
 
CodingExpertsCommented:
May be u find this url of some use ....

http://www.tek-tips.com/viewthread.cfm?qid=947659&page=1

-CE
0
 
girionisCommented:
> Caused by: java.io.InvalidClassException: common.Process; local class
> incompatible

This exception is thrown when you try to deserialie (unmarshal) an object you have received from a remote machien. It basically means that the version of the class in the error message is different between the two JVMs.

See also this message:

> stream classdesc serialVersionUID = -7788712377034963467, local class serialVersionUID = 2506602152668479765

they have different serialVersionUID.

Things to check:

1) Both computers have the exact same versin of JVM
2) Check that you have the proper jar files in your classpath
3) If all else fails you can try to manually add the serialVersionUID to the class itself by doing:

static final long serialVersionUID = <the serialization numeber>L;

If you need more info about serialization have a look here: http://www.acm.org/crossroads/xrds4-2/serial.html
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now