I'm trying to generate stub and skeleton files for my remote service, but all I'm getting is the stub file. I know that there's some option to not generate skeleton files, but I'm just using plain
command with no options.
Can anyone please help me figure this out? Do I need that skeleton file at all to run the service? (I believe I do, but who knows, maybe there were some changes made to the whole RMI thing in the last version of Java...) [ November 11, 2008: Message edited by: Slava Golovachenko ]
Thank you! That's what I suspected. It's weird though in Sun's Java manuals it's still said both are generated, as well as in Head First Java 2nd edition (covering Java 1.5). One more question. You say the stub file is not necessary anymore. How come I'm getting an error when running client side part of the app without the stub file in the same directory? Do I need to make any changes to the app in order for it to work without stubs?
Dynamic proxies will be used as stub if your remote object extends UnicastRemoteObject or it is exported using the static exportObject() method therein.(See release notes that i linked to earlier) How are you exporting your server and what is the excpetion you are getting at the client side? Is your client also on jdk 1.5? [ November 12, 2008: Message edited by: Nitesh Kant ]
Joined: Jun 05, 2008
I have the latest version of JDK and in fact the whole thing is running on one machine, I wrote a simple app that converts gas price in dollars per gallon to [other currency] per liter just to learn RMI. Here's what I get when no stub is present in the same directory as client.class (when it's there everything runs great):
Here's the code for my service .class file:
Here's the client part (no GUI stuff in this version to keep it simple):
Of course there's also that remote interface file, but nothing interesting in there.
You do not have the Interface definition in the client. Dynamic proxies require the interface definition. What RMI says is that the stub classes need not be there at the client/server. However, the interface definition has to be present or dynamic code downloading must be enabled. This is what that error is telling you.
Joined: Jun 05, 2008
Well, I'm not sure if it was what you're talking about or something else, but I recompiled the whole thing again, ran rmiregistry and the service (which of course I did before as well) and everything worked. I also created the GUI version of the app (all RMI stuff is same) and it works perfectly. Go figure... Anyway, thank you for answering my posts!
Thats great to hear! If you are learning RMI then I would suggest you to go back and take a stall of things and understand why it was not working before and why it worked now. It will help you.
My understanding is that the remote interface (GasPriceConverter) must be available with the client or Dynamic class downloading must be enabled at the server for things to work. If you feel that it is working even without this definition being at the client then there is something that you need to dig deep in.