This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes Cannot disconnect client properly from server. RMI. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Cannot disconnect client properly from server. RMI." Watch "Cannot disconnect client properly from server. RMI." New topic
Author

Cannot disconnect client properly from server. RMI.

Sven Sylta
Greenhorn

Joined: Aug 09, 2013
Posts: 27
I have a Client-class that connects to my local-server without problem. I'm not sure how to disconnect it properly though. Thanks for your help(Maybe I need to explain more?).



My Server-class
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2158
    
  47
Your client's disconnect method should be calling the server's unregister method (ie it should be basically the same as the client's connect method) rather than trying to unregister the server object from the RMI Registry.
Sven Sylta
Greenhorn

Joined: Aug 09, 2013
Posts: 27
Now I need to register every Client in my Server-class in order to be able to broadcast messages to all clients. So I'm trying to pass "this"-client as an argument to my server-registration-method but it is not working. It worked well just passing a "User" as an argument. Why can't I pass "this" ?

This is the new connect-method in the Client-class:


This is the new register-method in the server-class:


The error message:

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: edu.gu.hajo.mbclient.core.Client
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:353)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)......................
.................................................


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Cannot disconnect client properly from server. RMI.
 
Similar Threads
how to start server in command line...
can't solve the problem on RMI client code
how to perform database operations using rmi?
RMI client server don't work on ipv6 machines
RMI pass by value or by reference ?