aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI client failure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI client failure" Watch "RMI client failure" New topic
Author

RMI client failure

Amy Young
Greenhorn

Joined: Oct 04, 2007
Posts: 7
Hallo everybody

I'm doing the B&S assignment. I'm busy with the last part, setting up a network connection between the server and the client. I choose RMi.
I'm now able to start the server , and the RMI registry programatically.
When doing: netstat -na |grep 1099 I see that this port is listening.

Then I launch the Gui client , give as host : local host and as port 1099.
The client finds the registry for it doesn't fail doing:
DataRemoteFactory remoteFactory = (DataRemoteFactory) Naming.lookup(url);

But when asking to the server an instance of the object the client should use to talk to a failure takes place :

DataRemote remote = remoteFactory.getClient();


The url is correct. But this is the trace I receive: (HOpe is not too long)

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is:
java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.util.Collection suncertify.db.MyInterface.readAllRecords()
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:325)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:179)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at $Proxy0.getClient(Unknown Source)
at suncertify.remote.RmiClient.getRemote(RmiClient.java:42)
at suncertify.gui.controller.GuiController.<init>(GuiController.java:60)
at suncertify.gui.wiew.ClientWindow.<init>(ClientWindow.java:100)
at suncertify.gui.ApplicationRunner.<init>(ApplicationRunner.java:56)
at suncertify.gui.ApplicationRunner.main(ApplicationRunner.java:35)
Caused by: java.rmi.server.ExportException: remote object implements illegal remote interface; nested exception is:
java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.util.Collection suncertify.db.MyInterface.readAllRecords()
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:171)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:293)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:235)
at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:133)
at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:119)
at suncertify.remote.DataRemoteImpl.<init>(DataRemoteImpl.java:24)
at suncertify.remote.DataRemoteFactoryImpl.getClient(DataRemoteFactoryImpl.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException: illegal remote method encountered: public abstract java.util.Collection suncertify.db.MyInterface.readAllRecords()
at sun.rmi.server.Util.checkMethod(Util.java:244)
at sun.rmi.server.Util.getRemoteInterfaces(Util.java:223)
at sun.rmi.server.Util.getRemoteInterfaces(Util.java:193)
at sun.rmi.server.Util.createProxy(Util.java:126)
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:169)
... 17 more
Exception in thread "main" java.lang.NullPointerException
at suncertify.gui.controller.GuiController.getAllContractors(GuiController.java:96)
at suncertify.gui.wiew.ClientWindow.createAndShow(ClientWindow.java:128)
at suncertify.gui.wiew.ClientWindow.<init>(ClientWindow.java:104)
at suncertify.gui.ApplicationRunner.<init>(ApplicationRunner.java:56)
at suncertify.gui.ApplicationRunner.main(ApplicationRunner.java:35)


I've no idea what's going on... and that is just to little to go on.

Thank you in advance.

Amy
paul seldon
Greenhorn

Joined: Oct 26, 2006
Posts: 13
Exception in thread "main" java.lang.NullPointerException
at suncertify.gui.controller.GuiController.getAllContractors(GuiController.java:96)


First thing first.
Starting with this null pointer exception to be gone.
And then would you post again?
I would like to help you.
Amy Young
Greenhorn

Joined: Oct 04, 2007
Posts: 7
Hi Paul

I realize that I wasn't clear in describing the problem. I guess I've been looking at this for too long.
Let's start saying that when running the application in mode "alone" everything goes well.
The real problem is caused by calling:
DataRemote dr = new DataRemoteImpl(location);javascript: x()

DataRemoteImpl is defined as :

public class DataRemoteImpl extends UnicastRemoteObject implements DataRemote

In its constructor DataRemoteImpl instantiates the Data.java class which is the mandatory implementation of the DBAccess interface given by SUN in the assignement.And the constructor throws RemoteException.
The DataRemoteImpl calls all methods that can be found in the Data.java (as CreateRecord , deleteRecord etc).
This is the trace (I used a proef.java class to isolate the problem)

java.rmi.server.ExportException: remote object implements illegal remote interfa
ce; nested exception is:
java.lang.IllegalArgumentException: illegal remote method encountered: public a
bstract java.util.Collection suncertify.db.MyInterface.readAllRecords()
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:171)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:29
3)
at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:23
5)
at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:133)
at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:119)
at suncertify.remote.DataRemoteImpl.<init>(DataRemoteImpl.java:24)
at suncertify.remote.proef.<init>(proef.java:18)
at suncertify.remote.proef.main(proef.java:12)

It has something to do with the RMI implemetation, but I don't see what it is.
I hope this time I managed to be clear. I certanly don't want let people work on obvious issues.

Thanks

Amy
Michael Kelleher
Greenhorn

Joined: Aug 31, 2007
Posts: 17
One easy thing to make sure of that you have used 'serialver' to calculate a serialVersionUID value. If you do not, this values gets calculated by the JVM, and could potentially be a different value in different JVM's, or even the same JVM.

You probably already know this, but I thought it was worth mentioning.

Good luck, if anything else comes to mind, I will post again.
Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 416
    
    2

Does running rmic on your impl class help, even if not necessary for running in your case its useful for finding bugs particularly ones where a RemoteException declaration is missing or the like.


"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
Omer Haderi
Ranch Hand

Joined: Sep 27, 2006
Posts: 42
Hi,

make sure you throw RemoteException in all methods that you expose.
(methods of the class that extends the UnicastRemoteObject and implements the MyInterface)

99.9% that is your problem...

hope to help.
cheers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI client failure