Clicky

Java - RMI - Caused by: java.lang.IllegalArgumentException: illegal remote method encountered

September 16, 2013

Problem:

Caused by: java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.util.List suncertify.server.Server.getAccomodation()

Used Interface:

public interface Server extends java.rmi.Remote, Serializable {

List getAccomodation();

List getAccomodation(String criteria);

List getAccomodation(int recNo);

List bookAccomodation(int recNo);

}

Solution:

Java RMI and Remote interface make mandatory for all methods to throw RemoteException

public interface Server extends java.rmi.Remote, Serializable {

List getAccomodation() throws RemoteException;

List getAccomodation(String criteria) throws RemoteException;

List getAccomodation(int recNo) throws RemoteException;

List bookAccomodation(int recNo) throws RemoteException;

}

and 

(…)

/** 

* @return The Server

 * @throws RemoteException 

 */

public List getData() throws RemoteException{
    return server.getAccomodation();
}