Spring RMI服务器在ClassNotFoundException上失败:RmiInvocationHandler

时间:2014-06-22 04:48:07

标签: spring rmi

我正在使用spring rmi(版本3.2.1)并尝试连接到远程rmiregistry(" remote"在它未嵌入的意义上,rmi注册表在同一节点上运行但是一个不同的过程)。

尝试启动rmi服务器时出现此错误:

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)

1 个答案:

答案 0 :(得分:1)

rmi注册表无法访问spring rmi类。 (RmiInvocationHandler)。

您有两种选择:

  • 使用codebase属性启用动态类下载:请参阅:http://docs.oracle.com/javase/6/docs/technotes/guides/rmi/codebase.html

  • 使用CLASSPATH授予访问权限:只允许rmi注册表使用启动时所需的所有类。例如:

    export CLASSPATH = lib / spring-core-XXX.RELEASE.jar:lib / spring-context-XXX.RELEASE.jar:lib / your-other-classes-used-in-rmi.jar

    rmiregistry中