Forums Register Login

RemoteData Stub Error...

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
 


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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1014 times.
Similar Threads
unable to run client
NX:RMI exception
ClassCast Exception with RMI
Local mode - Remote mode
coupling between client and server Packages.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 20:05:54.