[英]Java RMI Client and Server Separate Machines
I want to edit the RMI hello world example to work with client and server on different machines, but i'm stuck with the unmarshalling return error. 我想编辑RMI hello world示例以在不同机器上使用客户端和服务器,但是我陷入了解组返回错误。
If i run client and server in the same project on Netbeans they work fine but when i split them i edited the try statement on the client side to be: 如果我在Netbeans的同一项目中运行客户端和服务器,则它们可以正常工作,但是当我拆分它们时,我在客户端将try语句编辑为:
try {
Registry registry = LocateRegistry.getRegistry("localhost");
String[] c = registry.list();
System.out.println(c[0].toString());
Remote lookup = Naming.lookup("HelloServer");
} catch (Exception e) {
System.out.println("HelloClient exception: " + e.getMessage());
}
without Remote lookup = Naming.lookup("HelloServer");
没有
Remote lookup = Naming.lookup("HelloServer");
, the print command gives "HelloServer" which is correct, but when i create the remote object I'm getting this error: ,打印命令给出的“ HelloServer”是正确的,但是当我创建远程对象时出现此错误:
HelloClient exception: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: rmimain.Hello
I've tested the policy and it's working fine, any help would be much appreciated. 我已经测试了该政策,并且该政策运行良好,非常感谢您的帮助。
您的客户端的CLASSPATH上没有rmimain.Hello类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.