previous chapter table of contents next chapter

RMI Stubs

A typical RMI stubs error looks like this:

 java.rmi.StubNotFoundException:   Stub class not found: rmi.FileClassifierImpl_Stub; nested exception is:   java.lang.ClassNotFoundException: rmi.FileClassifierImpl_Stub 

Many of the examples in this book export services as remote RMI objects. These objects are subclasses of UnicastRemoteObject . What gets exported is not the object itself, but a stub that will act as a proxy for the object (which continues to run back in the server). The stub has to be created using the rmic compiler, like this:

 rmic -v1.2 -d . rmi.FileClassifierImpl 

This will create a FileClassifierImpl_Stub.class in the rmi subdirectory. The stub class file needs to be accessible to the Java runtime in the same way as the original class file.

Another typical error is this:

 java.rmi.ServerException: RemoteException occurred in server thread; nestedexcep- tion is:   java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:   java.lang.ClassNotFoundException: rmi.FileClassifierImpl_Stub 

This error arises when an object is trying to get a remote reference to FileClassifierImpl , and it is trying to load the class file for the stub from an HTTP server. What makes this one particularly annoying is that it may not be referring to the FileClassifierImpl_Stub at all! The class will often implement a remote interface, such as RemoteFileClassifier . This, in turn , implements the common class FileClassifier , as shown in Figure 2-1.

Figure 2-1: Interfaces and superclasses for an exported stub

Class files for all of these classes and interfaces have to be available! The FileClassifier interface may be "well known," with a class file on each client and server. However, an interface such as RemoteFileClassifier , as well as the implementation files for FileClassifierImpl , may only be known to a particular server. The HTTP server must carry not only the class files for the stubs, but the class files for all superclasses and interfaces that are not available to all ”in this case, for RemoteFileClassifier as well as FileClassfier .


A Programmer[ap]s Guide to Jini Technology
A Programmer[ap]s Guide to Jini Technology
ISBN: 1893115801
Year: 2000
Pages: 189

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net