Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

RMI: strange inheritance behavior of Remote interface

843793Feb 17 2006 — edited Feb 20 2006
Hello all,

I've encountered a strange inheritance problem using RMI. Consider the following interfaces and classes :

public interface Product extends Remote {
public void doX() throws RemoteException;
}

public interface LocalProduct extends Product {
public void doX();
}

public class RMIServer {
public static void main(String[] args) {
try {
Product p = new ProductImpl();
UnicastRemoteObject.exportObject(p,0);
Naming.rebind("product", p);
} catch( Exception e) {
System.err.println(e);
}
}

If 'ProductImpl' is written like this, i.e. directly implements Product, everything works fine
public class ProductImpl implements Product {
public void doX() {
System.out.println("Do X called");
}
}

If 'ProductImpl' implements LocalProduct, an exception is throws:
public class ProductImpl implements LocalProduct {
public void doX() {
System.out.println("Do X called");
}
}
result in :
remote object implements illegal remote interface; nested exception is:
java.lang.IllegalArgumentException: illegal remote method encountered: public abstract void LocalProduct.doX()

So, when the concrete class directly implements the Product interface everything is ok, but when there is an intermediate interface (which is for local use), an exception is thrown.

Does anyone have any idea why this is the case?

Thanks in advance!
Gunther.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 20 2006
Added on Feb 17 2006
2 comments
564 views