Exception "remote object implements illegal remote interface"?
Asked Answered
C

1

16

I use rmi in Java. however there is a ExportException "remote object implements illegal remote interface".

Here is my code, May someone help me?

public interface RemotePeer extends Remote {

    public abstract void displayInf(String inf);

    public abstract void exit();

    public abstract boolean isActive();
}


 public class Peer implements RemotePeer{
        public Peer(){}
        ....

        public static void main(String[] args) {
           Peer p=new Peer()
           RemotePeer remoteP=(RemotePeer) UnicastRemoteObject.exportObject(p, 0);
           Registry registry = LocateRegistry.getRegistry();
           }
}
Conic answered 29/9, 2012 at 17:40 Comment(2)
Have you tried using UnicastRemoteObject?Infusion
@Abu Why? What difference would that make?Blindstory
M
45

Every method in a Remote interface must be able to throw a RemoteException. Your interface should be:

public interface RemotePeer extends Remote {

    public abstract void displayInf(String inf) throws RemoteException;

    public abstract void exit() throws RemoteException;

    public abstract boolean isActive() throws RemoteException;
}

You might want to take a look at the RMI Tutorial.

Marplot answered 29/9, 2012 at 17:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.