java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassCastException: java.io.ObjectStreamClass cannot be cast to java.lang.String
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at com.nxl.smssession.SessionRMI.<init>(SessionRMI.java:33)
at com.nxl.smssession.Main.main(Main.java:33)
Caused by: java.lang.ClassCastException: java.io.ObjectStreamClass cannot be cast to java.lang.String有人能解释一下为什么会发生这个错误吗?
当我执行RMI绑定操作时,会发生这种情况。
此问题仅在SOLARIS系统上发生,它在windows和Linux中运行良好。
下面是生成此错误的代码
public SessionRMI(String servicename) throws AlreadyBoundException {
SessionImpl service = new SessionImpl();
try {
logger.debug("Publishing the SMS Session endpoint " + servicename);
SessionIface stub = (SessionIface) UnicastRemoteObject.exportObject(service, 0);
Registry registry = LocateRegistry.getRegistry();
registry.rebind(servicename, stub);
logger.debug("SMS Session endpoint published successfully "+servicename);
} catch (RemoteException ex) {
logger.error(ex.toString()); ex.printStackTrace();
}
} 提前感谢
发布于 2010-08-19 12:48:39
不能反序列化的是存根本身。我会再次检查存根类的生成,并确保在Solaris框中没有任何旧的.class文件。
发布于 2013-02-24 21:57:20
我在RedHat上出了这个问题,我想可能是因为我启动了错误的rmiregistry版本.
我能够通过编程启动注册表来解决这个问题。在registry.rebind()之前添加以下内容
java.rmi.registry.LocateRegistry.createRegistry(1099);发布于 2010-08-19 11:02:49
如果没有其他信息,我只能说:
Object.toString();试制铸造
ObjectStreamClass osc = new ObjectStreamClass();
String str1 = (String)osc; // Throws ClasCastException
String str2 = osc.toString(); // always works if osc is not nullhttps://stackoverflow.com/questions/3521026
复制相似问题