private void startServer() { // snippet that starts the server on the local machine
try {
RemoteMethodImpl impl = new RemoteMethodImpl();
Naming.rebind( "Illusive-Server" , impl );
} catch(Exception exc) {
JOptionPane.showMessageDialog(this, "Problem starting the server", "Error", JOptionPane.ERROR_MESSAGE);
System.out.println(exc);
}
}
抛出此异常:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: Interfaces.RemoteMethodIntf
当我启动我的项目时,弹出一个JOptionPane消息提示开启服务器时遇到问题,然后出现上述异常。这是什么原因呢?
我不明白为什么异常的最后一条语句说类未找到,而我已经导入了正确的包。
java.rmi.server.UnicastRemoteObject
的前言。你只有在使用 Java < 1.5 或者不遵循这些指南时才需要生成存根类。因为你得到了那个异常,显然其中之一是真的。 - user207421export CLASSPATH=myLib.jar:myLib2.jar
设置CLASSPATH,在启动rmiregistry之前使我的工作正常。但是我正在进行生产部署,并注意到您在另一篇帖子中关于CLASSPATH仅适用于开发,而代码库配置更适合部署的评论。您是否理解应该清除部署的CLASSPATH,并且所有使用rmi的服务器和客户端都将在部署配置中使用代码库? - simgineer