Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Urgent

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • 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.
 
Milind Kulkarni
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic