gpt4 book ai didi

java RMI无法运行服务器

转载 作者:行者123 更新时间:2023-12-01 13:54:41 25 4
gpt4 key购买 nike

我正在与 RMI 作斗争。我对此完全陌生并尝试过this tutorial

我的所有类和接口(interface)都编译良好,但是当我尝试运行服务器类时,出现一些异常(如下所列),项目构建如下:

-pakage hello
--interface Hello.java
--class Server.java
--class Client.java

我做了 Somme 研究,他们总是建议更改安全策略文件。所以我在 java.policy 中添加了以下策略:

grant 
{
permission java.security.AllPermission "", "";
};

第二个“问题”:我运行 Linux mint,所以我开始明白我不需要运行 rmiregistry,这是正确的还是我也需要启动它以及我该怎么做。

列出的异常(exception)情况:

Server exception: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: hello.Hello
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: hello.Hello
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:419)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:378)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at hello.Server.main(Server.java:23)

有谁可以帮助我吗?

最佳答案

该错误清楚地表明找不到 hello.Hello 类。请确保它位于类路径中。你拥有link中的一切您提供的 - 部分启动 Java RMI 注册表、服务器和客户端

关于java RMI无法运行服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19681494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com