Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Remote Object having JFrame referrence  RSS feed

 
Rohan Amin
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys. In my remote object i am having a referrence to a jframe object. The thing is i am developing a game server. so when the one player makes the move then it is sent to server and server tells the other remote object to update its GUI.

So remote object is having referrence to the gui and when it receives the message it calls methods on the gui.

But i am getting a horrible error when i try to do this. This is code for the remoteobjectplayer



getting error message of marshalling and unmarshalling and that local jframe class something something. This must be some thing related to serialization. please let me know if you can figure this out.

Thanks
 
Rohan Amin
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the error i get when i run remoteobjectplayer.

java RemoteObjectPlayer
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.io.InvalidClassException: javax.swing.JFrame; local class incompati
ble: stream classdesc serialVersionUID = -2386951414768123374, local class seria
lVersionUID = -5208364155946320552
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:385
)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
66)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:707)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at RemoteObjectPlayer.main(RemoteObjectPlayer.java:63)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex
ception is:
java.io.InvalidClassException: javax.swing.JFrame; local class incompati
ble: stream classdesc serialVersionUID = -2386951414768123374, local class seria
lVersionUID = -5208364155946320552
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:375
)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
66)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:707)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.InvalidClassException: javax.swing.JFrame; local class incomp
atible: stream classdesc serialVersionUID = -2386951414768123374, local class se
rialVersionUID = -5208364155946320552
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:546)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:155
2)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:155
2)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
699)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:19
08)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
719)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
... 9 more
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error suggests that the versions of the class javax.swing.JFrame is not the same on client and server.
Are you having the same swing version both on client and server?
If not, then make sure you do that.
 
Rohan Amin
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are no jframes on the server side. Actually there is no need of having any graphics on the server. Everything will be done on the client side.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rohan Amin:
There are no jframes on the server side. Actually there is no need of having any graphics on the server. Everything will be done on the client side.


I assume that the JFrame is a part of the ClientGUI object you have shown in the code. The ClientGUI is a part of the RemoteObjectPlayer which is sent to the server in the addPlayer() call. So, while sending the RemoteObjectPlayer instance to the server, the embedded JFrame instance will also be sent.

So, even if you do not want the JFrame instance to go the server, it indeed is going and since the version of JFrame is different is server(This is clear from the exception reason), you are getting the exception.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest developing a more abstract representation of the display currently done in the JFrame. Then your client side would not have this version dependence.

Bill
 
Rohan Amin
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did modify the code now. There are three classes now The RemoteObjectPlayer is now a JPanel which contains the drawing canvas and also contains the label to display player moves. The jframe now takes as parameter a remote object player and adds it the contentpane. There is a third utility class that instantiates both of these classes and binds only the remoteobjectplayer. The thing is when a client registers with the server it passes a referrence to the server. But when server needs to call some methods back on the client to change the canvas display that doesnt work.

Well what i want is when the client connects to the server the server should have some mechanism of passing back some message or calling methods on the client side. so i made the client object also a remote object.

Is there some other alternative for server passing messages to client or calling methods on the client other than rmi.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this survey article for an overview.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!