This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes RMI- Problem with Serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Distributed Java
Reply Bookmark "RMI- Problem with Serialization" Watch "RMI- Problem with Serialization" New topic
Author

RMI- Problem with Serialization

Saskia Schreiber
Greenhorn

Joined: Jul 09, 2001
Posts: 12
Hi there,
I'm just testing some RMI-programms. I wrote an ServerImpl which got the method getJFrame() (it returns an JFrame) I've got the Interface which is extended from the RemoteInterface but when I want to start the Server it always brings me these errors:
java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.io.NotSerializableException: de.xx.test.ServerImpl
java.io.NotSerializableException: de.xx.test.ServerImpl
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
error marshalling arguments; nested exception is:
java.io.NotSerializableException: de.xx.test.ServerImpl
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at de.xx.test.ServerImpl.main(ServerImpl.java:31)
and here is my ServerImpl:
public class ServerImpl implements Saskia {
public ServerImpl() {
}
public JFrame getJFrame() throws RemoteException {
JFrame myFrame = new JFrame("Saskia's Test");
myFrame.setBackground(Color.blue);
myFrame.setBounds(100,100,100,100);
return myFrame;
}
public static void main(String[] args){
try {
ServerImpl si= new ServerImpl();
Naming.rebind("rmi://dpc04:7011/Server",(Remote)si);
}
catch (Exception ex) {
ex.printStackTrace();
System.out.println(ex.getLocalizedMessage());
}
}
}
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
JFrame is not serializable. A frame represents an OS resource and cannot be sent over the network. In general, things like GUI widgets, database connections and the like cannot be serialized and so cannot be passed into or returned from an RMI method.
- Peter
Saskia Schreiber
Greenhorn

Joined: Jul 09, 2001
Posts: 12
I implemented the interface Serializable to my Server-programm and now it's working fine (after I also added a RMISecurityManager to my program). I got a beautiful JFrame on the client although most RMI-books say that JFrame is not transportable over network... :-)
Marco Barenkamp
Ranch Hand

Joined: Aug 27, 2001
Posts: 94
Hi,
remember that the client only got a copy of the original frame
created on the server and not the object itself.
Implementing Serializable in RMI means 'passByValue'
------------------
Marco Barenkamp
____________________________________________
L M I N T E R N E T S E R V I C E S AG
Senior Trainer & Architect,
BEA Certified Enterprise Developer
Sun Certified Programmer for the Java2 Platform
Sun Certified Web Component Developer for the Java2 Platform
Sun Certified Developer for the Java 2 Platform
Sun Certified Enterprise Architect for the Java 2 Platform Enterprise Edition (PI)


Marco Barenkamp<br />_ _ _ _ _ ________________________ _ _ _ _ _ <br />L M I N T E R N E T S E R V I C E S AG<br /> <br />Head of Software Development<br /> <br /> <br />BEA Certified Enterprise Developer<br />Sun Certified Programmer for the Java2 Platform<br />Sun Certified Web Component Developer for the Java2 Platform<br />Sun Certified Developer for the Java 2 Platform <br />Sun Certified Business Component Developer for the Java 2 Platform <br />Sun Certified Enterprise Architect for the Java 2 Platform Enterprise Edition<br /> <br />LMIS AG
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI- Problem with Serialization
 
Similar Threads
NotSerializableException problem...
JBoss question: NotSerializable Exception
NotSerializableException
MarshalException occured when sending socket object to session bean
MarshalException and NotSerializableException in weblogic 6.1