• 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

Urgent

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is what I am trying to do and not able to get a solution.
public interface X extends Remote {
public void methodOne() throws RemoteException;
public Z methodTwo() throws RemoteException; //Z is a class
}
public class XImpl implements X {
public void methodOne() throws RemoteException {
// body
}
public Z methodTwo() throws RemoteException {
//body
return new Z();
}
}
public class MyServer {
public MyServer(){
X x=(X)new XImpl();
UnicastRemoteObject.exportObject(x);
Naming.rebind("rmi://localhost:1099/MyServer", x);
}
public static void main(String s[]) {
new MyServer();
}
}
Now when I call the methodOne from the client, it works fine but if I try to call methodTwo, the return type is null.
I tried creating an interface for Z(say ZInter) and made Z implement the interface ZInter and created the stub and the skeleton classes. But now, I do not know how do I refer them in the client.
Please reply ASAP.
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Smita,
Can you specify the details of Z class.
Regards,
Milind
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Z class is just another class that has a few data members, a few methods and the class implements Serializable.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Milind, I am still waiting for reply.
Please answer the query ASAP.
Smita.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Smita
According my view u should copy the class Z on to the client's
machine .Bcoz that return type will not be understood by jvm
which is not a standard class .
u can reach me at vish_venu9@hotmail.com
regards
venu
 
Milind Kulkarni
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Smita,
There is absolutely no difference in the way you call remote method (on the different host) and the local method ( on the same host). As pointed out by Venu make sure that your client can access Z class implementation either copying class Z in your client directory or dynamically loading class using CODEBASE.
Regards,
Milind
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Milind, Can you show it with the help of some sample code. It would be really helpful.
Thanks,
Smita.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Object you are passing must implement java.io.serializable. Once that is done it can be used as if it were local objects.
I coded and run a program very similar to the one you were trying to develop. It works fine.
If you want the source code please mail me at moh@srasys.co.in
or mohan@the-pentagon.com
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic