Suh*_*pta 8 java rmi exception
以下方法:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
抛出此异常: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中的消息,说服务器启动服务器然后出现上述异常.这可能是什么原因?
我不明白为什么最后一个异常声明说当我导入了正确的包时没有找到类
use*_*421 11
这种例外有三种情况.
导出时:您没有运行'rmic'并且您没有采用Javadoc前言中描述的步骤UnicastRemoteObject来使其不必要.
绑定时:注册表没有存根或远程接口或它们依赖于其类路径的东西.
查找时:客户端在类路径上没有这些东西.
这是案例2.注册表找不到指定的类.
有四种解决方案:
使用包含相关JAR或目录的CLASSPATH启动注册表.
通过服务器JVM启动注册表 LocateRegistry.createRegistry().
使用动态存根,如Javadoc前言中所描述的那样UnicastRemoteObject.你可能仍会遇到与远程接口本身或它依赖的类相同的问题,在这种情况下,上面的1-3仍然适用于那个类/那些类.
使用代码库功能.这实际上是一个部署选项,IMO在初始开发阶段应该避免.
小智 5
Remote Server Error:RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: mathInterface
Run Code Online (Sandbox Code Playgroud)
该错误很简单,只需执行以下步骤即可解决:
(无论您的文件在哪里,都开始rmiregistry)
| 归档时间: |
|
| 查看次数: |
49309 次 |
| 最近记录: |