Reputation: 1
i programmed an RMI-Example and now the problem with my Program is, i'm trying to terminate or close the Server if the User puts in "closeBookManager()"
. Consider following Code :
if(in.equals("closeBookManager()")) {
service.closeBookManager();
break;
}
This piece of code is within a while loop, which is always true, until the user types in "closeBookManager()"
Now the problem is if the user types in that mentioned string, i would like to close the Server. I tried it with System.exit(0)
on the Server Side
public void closeBookManager() throws RemoteException {
...
System.exit(0);
}
but it throws this Error on the Client Side :
Exception in thread "main" java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is: java.io.EOFException at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:229) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162) at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227) at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179) at com.sun.proxy.$Proxy0.closeBookManager(Unknown Source) at Client.main(Client.java:66) Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:267) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:215) ... 5 more
I also tried to unbind and unexport the Object but it wont work.
Please tell me what am i doing wrong or what could i do. I will appreciate any help :)
Upvotes: 0
Views: 440
Reputation: 311039
Have it exit in a separate thread after a short delay to allow time for the remote method to complete and send its result back.
Upvotes: 0