Note that there are some explanatory texts on larger screens.

plurals
  1. POIllegal remote method in java
    text
    copied!<p>It's the first time I use java Rmi*. I have a custom class which extends <code>UnicastRemoteObject</code> and implements an interface which extends remote. I think that I have implemented the methods of the interface correctly in the class but still I get an <code>IllegalArgumentException</code> when I try to run my code (and it's about a method which has no arguments).</p> <p>The jvm claims to have encountered an illegal remote method but the method and its implementation seem fine to me. </p> <p>Is there any other reason as a result of which this exception might occur except for implementing or calling the method wrongly?</p> <hr> <p>Here's the stack trace:</p> <pre><code>SEVERE: null java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is: java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.lang.String Node.getId() at sun.rmi.server.UnicastServerRef.exportObject(Unknown Source) at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source) at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source) at java.rmi.server.UnicastRemoteObject.&lt;init&gt;(Unknown Source) at java.rmi.server.UnicastRemoteObject.&lt;init&gt;(Unknown Source) at NodeImpl.&lt;init&gt;(NodeImpl.java:30) at NodeLauncher.main(NodeLauncher.java:11) Caused by: java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.lang.String Node.getId() at sun.rmi.server.Util.checkMethod(Unknown Source) at sun.rmi.server.Util.getRemoteInterfaces(Unknown Source) at sun.rmi.server.Util.getRemoteInterfaces(Unknown Source) at sun.rmi.server.Util.createProxy(Unknown Source) ... 7 more </code></pre> <p>Here's the interface:</p> <pre><code>import java.rmi.*; import java.util.LinkedList; interface Node extends Remote { public boolean isAlive(); public LinkedList&lt;NodeImpl&gt; getLeafNodes(); public LinkedList&lt;NodeImpl&gt; getNeighborhoodList(); public String [] getRoutingTable(); public NodeImpl initiation(String credentials,Object application); public String route(String message,String key); public void inform(byte [] id); public String getId(); public boolean isConnected(); public void applicationClose(); public boolean distanceMeasure(); } </code></pre> <p>and here's the constructor of the class:</p> <pre><code>public NodeImpl() throws RemoteException { super(); l=4; M=1; nodeId=new byte [16]; Random r=new Random(); r.nextBytes(nodeId); leafNodes=new LinkedList&lt;NodeImpl&gt;(); connected=false; ng=new NodeGUI(this); for(int i=0;i&lt;l;i++) { leafNodes.add(null); } neighborhoodList=new LinkedList&lt;NodeImpl&gt;(); anyNodeWhoAnswered=new LinkedList&lt;byte []&gt;(); it=new InformingTimer(this); Thread informingTimerThread=new Thread(it); informingTimerThread.start(); try { Naming.rebind("rmi://" + "localhost" + ":1099/"+nodeId, this); } catch (Exception ex) { Logger.getLogger(NodeImpl.class.getName()).log(Level.SEVERE, null, ex); } bootstrap(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload