• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RemoteData Stub Error...

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am building the basic functionality for client-server communication using RMI.
When I try to lookup the RemoteData object (present in "suncertify.server" package) from a client (present in "client" package), I get
the following error:
RemoteConnection exception: suncertify.server.RemoteData_Stub
java.lang.ClassCastException: suncertify.server.RemoteData_Stub
at client.RemoteConnection.getConnection(RemoteConnection.java:11)
at client.clientTest.main(clientTest.java:258)
Remote Implementation available.
Exception in thread "main" java.lang.NullPointerException
at client.clientTest.<init>(clientTest.java:63)
at client.clientTest.main(clientTest.java:259)
But, when I copy the client class to the "suncertify.server" and access the RemoteData object, the application is running. Where am I making a mistake?!
I also tried copying the RemoteData_Stub to the "client" folder, but still the above error was thrown.
(RemoteData is the class which extends extends UnicastRemoteObject and implements DBMain (which extends Remote). RemoteData's main method binds the RemoteData object with the rmi-registry. The client lookups this object using rmi://ipaddress/obj)
Dayanand.
 
Dayanand Kangala
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please note: in the above error message, "Remote Implementation available." is not part of the error message ! (I had a System.out.println )
[ September 26, 2002: Message edited by: Dayanand Kangala ]
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I also tried copying the RemoteData_Stub to the "client" folder, but still the above error was thrown.


Are you making use of codebase parameter and policy file? Try to run your app without them.
Eugene.
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dayanand,
It looks to me like your trying to cast to the object instead of the interface. You can only cast to a Remote interface on the client thru RMI. That's why it works on the server when not using RMI.
Hope this helps,
Michael Morris
 
Dayanand Kangala
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eugene Kononov:

Are you making use of codebase parameter and policy file? Try to run your app without them.
Eugene.


Hi Eugene,
I ran the client without specifying the codebase and policy file.
The following is my directory structure:
workspace
-> Project
---> client
---> suncertify
-------> data
-------> server
I have given "Full Permission" to the directory "workspace", using policytool.
Dayanand.
 
Dayanand Kangala
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Morris:
Hi Dayanand,
It looks to me like your trying to cast to the object instead of the interface. You can only cast to a Remote interface on the client thru RMI. That's why it works on the server when not using RMI.
Hope this helps,
Michael Morris


Hi Michael,
The following are what I use in the "client":
ConnectionFactory (an interface)
LocalConnection implements ConnectionFactory
RemoteConnection implements ConnectionFactory
When the client is started with "alone" (or) no parameters, the LocalData object is returned by LocalConnection. When the client is started with "server" as parameter, I connect to RMI Registry to get the RemoteData object.
For both, I do the following in client:
DBMain obj = (DBMain) LocalData.getConnection();
(or)
DBMain obj = (DBMain) RemoteData.getConnection();
DBMain is an interface. LocalData and
RemoteData implements this interface. I am not sure if this is done properly.
The following is what I have done:
I have DBMain interface in the "client" package as well as in the "suncertify.server" package. The only difference between these files is that the DBMain interface in the "suncertify.server" package "extends Remote" and all methods "throws RemoteException". The RemoteData (in suncertify.server package) implements the DBMain interface (in the suncertify.server package). When I get the RemoteData object I cast it to DBMain interface (as shown above - in the client package).
Should I copy the DBMain interface used in the "suncertify.server" package in "client" package?
Dayanand.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dayanand,
ConnectionFactory has to extend Remote also. Here's what you need to do to get your connection:

Your ConnectionFactory should be bound to the RMI registry with some appropriate name using Naming.rebind() on the server.
Hope this helps,
Michael Morris
 
Dayanand Kangala
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Morris:
Hi Dayanand,
ConnectionFactory has to extend Remote also. Here's what you need to do to get your connection:

Your ConnectionFactory should be bound to the RMI registry with some appropriate name using Naming.rebind() on the server.
Hope this helps,
Michael Morris


Thanks Michael,
I extended the ConnectionFactory as Remote, tried various other things (for a lonng time - 2 days) and finally the client-server communication is happening
Dayanand
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic