java.io.ObjectStreamClass 无法转换为 java.lang.String
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();
}
}
提前致谢
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
Can someone explain why this error is happening
This is happening when i am doing RMI Bind Operation
This problem is happening on SOLARIS System only, it is working fine in windows and Linux
Here is the code which generates this error
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();
}
}
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
存根本身无法反序列化。我会仔细检查存根类的生成,并确保 Solaris 机器上没有任何旧的 .class 文件。
It's the stub itself that can't be deserialized. I would double-check the generation of your stub class, and make sure you don't have any old .class files lying around on the Solaris box.
我在 RedHat 上遇到了这个问题,我认为这可能与我启动错误的 rmiregistry 版本有关...
我能够通过以编程方式启动注册表来解决这个问题。在registry.rebind()之前添加此内容
I had this problem on RedHat, i think it might have been to do with me starting the wrong rmiregistry version ...
I was able to solve this issue by starting the registry programmatically. Add this before registry.rebind()
看起来您有一个需要
String
参数的远程方法,但您给它一个java.io.ObjectStreamClass
代替。这当然会引发UnmarshalException
。您应该仔细检查您的 RMI 绑定操作尝试,并确保您尝试调用正确的方法,并且在需要时提供正确的参数。请查阅文档以确认
String
参数应该代表什么,并相应地提供它。参考文献
It looks like you have a remote method that expects a
String
argument, but instead you give it ajava.io.ObjectStreamClass
instead. This will of course raise anUnmarshalException
.You should carefully examine your RMI bind operation attempt and ensure that you are trying to invoke the right method, and you're providing the right arguments wherever needed. Consult the documentation to confirm what the
String
argument is supposed to represent, and provide it accordingly.References
谢谢你们的帮助。
我自己解决了这个问题。
看起来 rmiregistry 在 Solaris 系统上没有像在 Windows 和 Linux 中那样启动。
我必须从代码本身手动启动它。
Thanks for the help guys.
I solved the problem myself.
It seems like the rmiregistry was not starting up on the solaris system as it does in windows and linux.
I had to manually start it from within the code itself.
没有额外的信息我只能说:
代替铸造尝试Object.toString();
Without additional info i can only say:
Intead of casting try Object.toString();