• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

RMI with JavaSE 6 - UnicastRemoteObject.exportObject(Remote object) fails  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working with RMI on JAVA SE 6 by following this guide. Currently i am facing exception when i try to use UnicastRemoteObject.exportObject(Remote object) whereas UnicastRemoteObject.exportObject(Remote object, Port port) is successfull.

According to javadoc for java.lang.UnicastRemoteObject, UnicastRemoteObject.exportObject(Remote object)

Exports the remote object to make it available to receive incoming calls using an anonymous port.



Here is the Server Class:


Error Trace:
java.rmi.StubNotFoundException: Stub class not found: com.vivek.core.rmi.server.HelloWorldServer_Stub; nested exception is:
java.lang.ClassNotFoundException: com.vivek.core.rmi.server.HelloWorldServer_Stub

There is no need for "rmic" as in the same document it is mentioned

Note: As of the J2SE 5.0 release, stub classes for remote objects no longer need to be pregenerated using the rmic stub compiler, unless the remote object needs to support clients running in pre-5.0 VMs. If your application needs to support such clients, you will need to generate stub classes for the remote objects used in the application and deploy those stub classes for clients to download



Would someone guide me why this is happening ?
 
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per these release notes:

The static method UnicastRemoteObject.exportObject(Remote) is declared to return java.rmi.server.RemoteStub and therefore cannot be used to export a remote object to use a dynamically generated stub class for its stub. An instance of a dynamically generated stub class is a java.lang.reflect.Proxy instance which is not assignable to RemoteStub.



So, either you have to extend UnicastRemoteObject or use UnicastRemoteObject.exportObject(Remote object, Port port) which you have already discovered to be working.
 
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Classpath.

Although the stub may be generated automatically, you still need to set a classpath (current dir, etc) for the Registry.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Edward Harned wrote:Although the stub may be generated automatically, you still need to set a classpath (current dir, etc) for the Registry.



Not atleast for the dynamic proxy.
 
Vivek Kr Singh
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much for your answers.
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!