Hi,
I'm writing my first RMI application, it's an auction system. At the end of the auction period for a particular item the server sends a 'callback' to the winning client telling him that he's won. It works fine till here, but after that i get this exception. It shows on the client console, but i suspect it's coming from the server. Any clues what's going on here? Please let me know if you need to see the client or server code.
I use java rmi client and server.
This is the exception below:
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:209)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
at das.auction.client.ClientDriver_Stub.notify(Unknown Source)
at das.auction.server.RemoteAuctionImpl.notifyWinnerInfo(RemoteAuctionImpl.java:220)
at das.auction.server.RemoteAuctionImpl$BidTimeReached.run(RemoteAuctionImpl.java:75)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:250)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:195)
... 6 more
This is code where i call client callback method in server. the stack comes from the catch block of this method.
public void notifyWinnerInfo(String itemCodeId,String userId,Integer maxBidVal)
{
try
{
System.out.println("update winner and notify clients");
Set<Map.Entry<Subscriber,UserInfo>> subsUserMapArray = subscriberList.entrySet();
Iterator it = subsUserMapArray.iterator();
Subscriber winner;
System.out.println("# of elements in iterator " + subsUserMapArray.size());
while(it.hasNext())
{
System.out.println("element found");
Map.Entry<Subscriber,UserInfo> m = (Map.Entry<Subscriber,UserInfo>)it.next();
UserInfo uid = m.getValue();
Subscriber s = m.getKey();
if(uid.getUID().equals(userId))
{
s.notify(itemCodeId,maxBidVal,Boolean.TRUE);
}
else
{
s.notify(itemCodeId,maxBidVal,Boolean.FALSE);
}
}
}
catch(Exception re)
{
System.out.println("UpdateUserBid"); // This is where the stack comes from, i get this system.out
re.printStackTrace();
}
}
This is the client code for this callback
public void notify(String itemCodeId,Integer maxBidVal,Boolean winner)
{
System.out.print((char)27 + "[2J");
System.out.println("server notification: " + " ItemCodeId: " + itemCodeId + " maxBidVal: " + maxBidVal + " winner?: " + winner);
if(!winner)
{
System.out.println("Sorry, you were not the highest bidder");
}
else
System.out.println("Congrats !! you have won the bid for this item, Please see our website for payment options");
//sleep here for sometime then go to first screen again
ClientStateMachine.nextItem = "WELCOME";
ClientStateMachine.run();
}
as soon as i do anything on the first screen now, i get the stack.