My RMI server interface declares a method foo() which is declared to throw RemoteException and Exception, as follows:
public interface Node extends RemoteService {
public void foo() throws RemoteException, Exception;
}
The server implementation is:
public class NodeImpl extends UnicastRemoteObject implements Node {
public void foo() throws RemoteException, Exception {
// Implementation - calls other stuff...
}
}
My client calls foo on the server:
try {
node.foo();
}
catch (Exception e) {
System.err.print("Got exception from foo() of type " + e.getClass().getName());
System.err.println("Exception: " + e.getMessage());
}
Now when I run the client I get:
Got exception from foo() of type java.rmi.UnexpectedException Exception: undeclared checked exception; nested exception is: java.io.InterruptedIOException: The operation timed out
Java doc says this about java.rmi.UnexpectedException:
An UnexpectedException is thrown if the client of a remote method call receives, as a result of the call, a checked exception that is not among the checked exception types declared in the throws clause of the method in the remote interface.
But my remote interface specifies that foo() throws Exception, and java.io.InterruptedIOException is a kind of Exception. So why does my client get UnexpectedException?
Thanks, Tom
caughtthe exception and is executing the print statements that you have declared, what is the problem? - RossBille