Java – RMI server exception

When I try to run a server using a remote registry, I get the following exception from RMI

The registry code of my main method in the server2 class is

Registry registry = LocateRegistry.getRegistry("192.168.1.4",1100);
registry.rebind("Hello",stub);

192.168. 1.4 is another machine in the same LAN

Please help me

Server2 exception:java.rmi.ServerException: remoteexception occurred in server thread; nested exception is: 
 java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
 java.lang.ClassNotFoundException: example.Hello.RemoteHello2
java.rmi.ServerException: remoteexception occurred in server thread; nested exception is: 
 java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
 java.lang.ClassNotFoundException: example.Hello.RemoteHello2
 at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396)
 at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
 at sun.rmi.transport.Transport$1.run(Transport.java:159)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
 at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 at java.lang.Thread.run(Thread.java:619)
 at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
 at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
 at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
 at sun.rmi.registry.RegistryImpl_Stub.rebind(UnkNown Source)
 at example.Hello.Server2.main(Server2.java:29)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
 java.lang.ClassNotFoundException: example.Hello.RemoteHello2
 at sun.rmi.registry.RegistryImpl_Skel.dispatch(UnkNown Source)
 at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386)
 at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
 at sun.rmi.transport.Transport$1.run(Transport.java:159)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
 at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 at java.lang.Thread.run(Thread.java:619)

I have a class named remotehello2. I can confirm this because another server program in the same package is running normally

I have two server programs, one uses localhost as the registry, and the second uses remote server as the registry

Solution

I have this problem It turns out that I have started the RMI registry from the command prompt as normal, but I am not communicating with server Class in the same folder When I change the directory to server There is no problem with the location of class

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>