Oracle 페이지에서 Hello World RMI 예제를 실행하려고했지만 오류가 계속 발생합니다. java.rmi.NoSuchObjectException : 테이블 java.rmi.NoSuchObjectException에서 그러한 목적 : sun.rmi.transport에서 테이블에 이런 개체RMI 해당 오브젝트 예외 없음
내가 점점 계속 오류가
내가 사용하는 사이트에서 직접 촬영으로 코드입니다서버 예외입니다. 일에서 sun.rmi.server.UnicastRef.invoke에서 StreamRemoteCall.exceptionReceivedFromServer sun.rmi.transport.StreamRemoteCall.executeCall (StreamRemoteCall.java:252)에서 (StreamRemoteCall.java:275) (UnicastRef.java:378) .rmi.registry.RegistryImpl_Stub.bind (알 수없는 소스) ( ) example.hello.Server.main
헬로 인터페이스 : (Server.java:26는) 다음
패키지 example.hello;
package example.hello;
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("localhost");
registry.bind("Hello", stub);
System.err.println("Server ready");
} catch (Exception e) {
System.err.println("Server exception: " + e.toString());
e.printStackTrace();
}
}
}
클라이언트 코드 :
package example.hello;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Client {
private Client() {}
public static void main(String[] args) {
String host = "localhost";
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();
}
}
}
이 모든 의견이 크게 감사합니다
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}
이것은 무엇을 내 서버 클래스입니다!
가능한 복제본은 [java.rmi.NoSuchObjectException : 테이블에 해당 객체 없음]입니다 (http://stackoverflow.com/questions/645208/java-rmi-nosuchobjectexception-no-such-object- in-table) –