[TOC] [Prev] [Next]

Exceptions In RMI


Exceptions During Remote Object Export

When a remote object class is created that extends UnicastRemoteObject, the object is exported, meaning it can receive calls from external Java virtual machines and can be passed in an RMI call as either a parameter or return value. An object can either be exported on an anonymous port or on a specified port. For objects not extended from UnicastRemoteObject, the java.rmi.server.UnicastRemoteObject.exportObject method is used to explicitly export the object.
Exception Context
  1. Class of stub not found.
  2. Name collision with class of same name as stub causes one of these errors:
    • Stub can't be instantiated.
    • Stub not of correct class.
  3. Bad URL due to wrong codebase.
  4. Stub not of correct class.
  1. Class of skeleton not found.
  2. Name collision with class of same name as skeleton causes one of these errors:
    • Skeleton can't be instantiated.
    • Skeleton not of correct class.
  3. Bad URL due to wrong codebase.
  4. Skeleton not of correct class.
java.rmi.server.ExportException The port is in use by another VM.

Exceptions During RMI Call
Exception Context
java.rmi.UnknownHostException Unknown host.
java.rmi.ConnectException Connection refused to host.
java.rmi.ConnectIOException I/O error creating connection.
java.rmi.MarshalException I/O error marshaling transport header, marshaling call header, or marshaling arguments.
java.rmi.NoSuchObjectException Attempt to invoke a method on an object that is no longer available.
java.rmi.StubNotFoundException Remote object not exported.

Exceptions or Errors During Return
Exception Context
  1. Corrupted stream leads to either an I/O or protocol error when:
    • Marshaling return header.
    • Checking return type.
    • Checking return code.
    • Unmarshaling return.
  2. Return value class not found.
java.rmi.UnexpectedException An exception not mentioned in the method signature occurred, including runtime exceptions on the client. An exception object contains the actual exception.
java.rmi.ServerError Any error that occurs while the server is executing a remote method.
java.rmi.ServerException Any remote exception that occurs while the server is executing a remote method. For examples, see Possible Causes of java.rmi.ServerException.
java.rmi.ServerRuntimeException Any runtime exception that occurs while the server is executing a method, even if the exception is in the method signature. This exception object contains the underlying exception.

Possible Causes of java.rmi.ServerException

These are the underlying exceptions which can occur on the server when the server is itself executing a remote method invocation. These exceptions are wrapped in a java.rmi.ServerException; that is the java.rmi.ServerException contains the original exception for the client to extract. These exceptions are wrapped by ServerException so that the client will know that its own remote method invocation on the server did not fail, but that a secondary remote method invocation made by the server failed.
Exception Context
java.rmi.server.SkeletonMismatchException Hash mismatch of stub and skeleton.
java.rmi.UnmarshalException I/O error unmarshaling call header. I/O error unmarshaling arguments.
java.rmi.MarshalException Protocol error marshaling return.
java.rmi.RemoteException Method number out of range due to corrupted stream.

Naming Exceptions

The following table lists the exceptions specified in methods of the java.rmi.Naming class and the java.rmi.registry.Registry interface.
Exception Context
java.rmi.AccessException Operation disallowed. The registry restricts bind, rebind, and unbind to the same host. The lookup operation can originate from any host.
java.rmi.AlreadyBoundException Attempt to bind a name that is already bound.
java.rmi.NotBoundException Attempt to look up a name that is not bound.
java.rmi.UnknownHostException Attempt to contact a registry on an unknown host.

Other Exceptions
Exception Context
java.rmi.RMISecurityException A security exception that is thrown by the RMISecurityManager.
java.rmi.server.ServerCloneException Clone failed.
java.rmi.server.ServerNotActiveException Attempt to get the client host via the RemoteServer.getClientHost method when the remote server is not executing in a remote method.
java.rmi.server.SocketSecurityException Attempt to export object on an illegal port.

[TOC] [Prev] [Next]

Copyright © 1996, 1997 Sun Microsystems, Inc. All rights reserved.