简体   繁体   English

Java RMI-注册表绑定调用导致NoSuchObjectException

[英]Java RMI - registry bind call results in NoSuchObjectException

I got an simple program that should make calcPi() avaible over Java-RMI, when I start the programm I get this exception: 我有一个简单的程序,该程序应可使calcPi()在Java-RMI上可用,当我启动该程序时,出现以下异常:

java.rmi.NoSuchObjectException: no such object in table
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
    at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
    at sun.rmi.server.UnicastRef.invoke(Unknown Source)
    at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
    at server.CalculatePi.main(CalculatePi.java:24)

Here's my code and below the interface: 这是我的代码,并且在界面下方:

public class CalculatePi implements ICalculatePi {
    @Override
    public Double calcPi() throws RemoteException{
    return 3.141259;
}

public static void main(String[]args){
    if(System.getSecurityManager()==null){
        System.setProperty("security.policy","file:./security.policy");
    }
    try{

        String name="Pi-Rechner";
        ICalculatePi rechner=new CalculatePi();
        ICalculatePi stub=(ICalculatePi) UnicastRemoteObject.exportObject(rechner, 0);
        Registry myRegistry=LocateRegistry.getRegistry();
        myRegistry.rebind(name,stub);
        System.out.println("Rechner gebunden!");
    }catch(Exception e){
        e.printStackTrace();
    }
}

} }

and here's my Interface: 这是我的界面:

package server;

import java.rmi.Remote;
import java.rmi.RemoteException;

public interface ICalculatePi extends Remote {
    public Double calcPi() throws RemoteException;
}

I followed the tutorial while programming: http://docs.oracle.com/javase/tutorial/rmi/implementing.html 我在编程时遵循了该教程: http : //docs.oracle.com/javase/tutorial/rmi/implementing.html

Thanks if someone got a good and easy solution! 谢谢,如果有人得到了一个好而简单的解决方案!

You have another RMI process running on your system, exported on port 1099, but it's not an RMI registry. 您在系统上运行了另一个RMI进程,并在端口1099上导出了该进程,但这不是RMI注册表。 Find that process, kill it, and run an RMI registry (typically the rmiregistry command). 找到该进程,将其杀死,然后运行RMI注册表(通常是rmiregistry命令)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM