- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遵循了本教程:https://docs.oracle.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html#5
我在命令提示符下编译了它们,然后启动了 rmiregistry。然后,在我输入后:
start java -classpath "." example.Server
它没有显示“服务器就绪”。但是,它也没有显示任何错误。
当我在 Eclipse 上尝试时,它显示了以下内容:
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: example.Hello
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: example.Hello
Hello.java
package example;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Hello extends Remote
{
String sayHello() throws RemoteException;
}
服务器.java
package example;
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class Server implements Hello
{
public Server() {}
public String sayHello()
{
return "Hello, world!";
}
public static void main(String args[]) {
try {
Server obj = new Server();
Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0);
// Bind the remote object's stub in the registry
Registry registry = LocateRegistry.getRegistry();
registry.bind("Hello", stub);
System.err.println("Server ready");
} catch (Exception e) {
System.err.println("Server exception: " + e.toString());
e.printStackTrace();
}
}
}
客户端.java
package example;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Client
{
private Client() {}
public static void main(String[] args)
{
String host = (args.length < 1) ? null : args[0];
try {
Registry registry = LocateRegistry.getRegistry(host);
Hello stub = (Hello) registry.lookup("Hello");
String response = stub.sayHello();
System.out.println("response: " + response);
} catch (Exception e) {
System.err.println("Client exception: " + e.toString());
e.printStackTrace();
}
}
}
我是否遗漏了任何步骤?我该怎么办?
最佳答案
ClassNotFoundException: example.Hello
- 您的应用程序找不到此类。将此类添加到客户端和服务器的类路径中。
如果您在 Sserver 之外的其他 PC 上启动客户端,请不要忘记将您的类 example.Hello
与您的客户端一起复制。
关于java - RMI:ServerException、RemoteException、UnmarshalException、UnmarshalException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58191796/
当尝试从客户端访问 ejb 时,我收到此异常: java.rmi.ServerException: RuntimeException; nested exception is: java.lang
在 Azure 中定义警报时,我可以选择一个“信号”。与我相关的两个是:异常和服务器异常。两者有什么区别?我找不到任何涉及这两者的文档。在哪里可以看到“服务器异常”发生情况? 最佳答案 答案很简单:
我遵循了本教程:https://docs.oracle.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html#5 我在命令提示符下
我正在尝试使用 C# 中的客户端对象模型以编程方式将讨论帖子插入到 Sharepoint 讨论板列表中。我正在使用以下代码: var discussionList = sharepointConte
我正在使用 Guzzle(最新的 5.2)对服务器进行 POST 调用。此服务器上的 API 返回“HTTP/1.1 500 内部服务器错误”响应,但也返回一个正文。如何访问异常响应的主体? 以下是我
此错误阻止我运行该项目。 以下是版本信息: ~ ❯❯❯ java -version java version "1.8.0_45" Java(TM) SE Runtime Environment (b
我有一个 Java 非 Web 应用程序,它以编程方式启动 Jetty 服务器以提供 API 访问权限。它们之间的通信是通过 RMI 完成的。在我启动与该项目没有任何关系的 Tomcat 之前,一切正
以下方法: private void startServer() { // snippet that starts the server on the local machine
以下方法: private void startServer() { // snippet that starts the server on the local machine
以下方法: private void startServer() { // snippet that starts the server on the local machine
以下方法: private void startServer() { // snippet that starts the server on the local machine
我正在 scala 中运行我的第一个程序来打印 hello world。程序如下 object Main { def main(args: Array[String]) { println
以下方法: private void startServer() { // snippet that starts the server on the local machine
以下方法: private void startServer() { // snippet that starts the server on the local machine
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
看来我的redis服务器不工作了,谁能解决这个问题?提前谢谢你 public static function getActiveUser($len = 10) { $key =
运行 Server 类(使用 java server 命令)时出现异常,如下所示(我已经启动了 rmiregistry,使用 start rmiregistry 命令)。可能是什么问题呢? C:\Us
请帮忙。 我一步步按照教程Laravel 5.3 中的新增功能:Laravel Passport ( https://laracasts.com/series/whats-new-in-laravel
当我通过 eclipse 运行我的服务器代码时,出现以下异常: java.rmi.ServerException: RemoteException occurred in server thread;
以下方法: private void startServer() { // snippet that starts the server on the local machine try {
我是一名优秀的程序员,十分优秀!