I am using spring rmi (version 3.2.1) and trying to connect to a remote rmiregistry ("remote" in the sense that it is not embedded, the rmi registry runs on the same node but as a different process).
I get this error when trying to start rmi server:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: org.springframework.remoting.rmi.RmiInvocationHand ler
at sun.rmi.server.UnicastServerRef.oldDispatch(Unicas tServerRef.java:419)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:1 77)
at sun.rmi.transport.Transport$1.run(Transport.java:1 74)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport. java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages( TCPTransport.java:556)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run0(TCPTransport.java:811)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(TCPTransport.java:670)
at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
at sun.rmi.transport.StreamRemoteCall.exceptionReceiv edFromServer(StreamRemoteCall.java:275)
at sun.rmi.transport.StreamRemoteCall.executeCall(Str eamRemoteCall.java:252)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:3 78)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at org.springframework.remoting.rmi.RmiServiceExporte r.prepare(RmiServiceExporter.java:291)
The rmi registry can't access to spring rmi classes. (RmiInvocationHandler
).
You have two options:
Enable dynamic class downloading using the codebase property: see: http://docs.oracle.com/javase/6/docs/technotes/guides/rmi/codebase.html
Give access using CLASSPATH: Just allow the rmi registry to use all classes that it will need at startup. For example:
export CLASSPATH=lib/spring-core-XXX.RELEASE.jar:lib/spring-context-XXX.RELEASE.jar:lib/your-other-classes-used-in-rmi.jar
rmiregistry