Results 1 to 3 of 3
  1. #1
    yolimau is offline Member
    Join Date
    May 2010
    Posts
    8
    Rep Power
    0

    Default Serialization problem

    Hi all,
    im programming a application in a plataform that uses RMI, and when i have to move some information i have this error:

    java.rmi.MarshalException: error marshalling arguments; nested exception is:
    java.io.NotSerializableException: java.io.PrintWriter
    at sun.rmi.server.UnicastRef.invoke(Unknown Source)
    at java.rmi.server.RemoteObjectInvocationHandler.invo keRemoteMethod(Unknown Source)
    at java.rmi.server.RemoteObjectInvocationHandler.invo ke(Unknown Source)
    at $Proxy0.moveAgentReceive(Unknown Source)
    ....
    Caused by: java.io.NotSerializableException: java.io.PrintWriter
    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    at java.io.ObjectOutputStream.defaultWriteFields(Unkn own Source)
    at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
    at java.io.ObjectOutputStream.writeOrdinaryObject(Unk nown Source)
    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    at sun.rmi.server.UnicastRef.marshalValue(Unknown Source)java.rmi.MarshalException: error marshalling arguments; nested exception is:
    java.io.NotSerializableException: java.io.PrintWriter
    at sun.rmi.server.UnicastRef.invoke(Unknown Source)
    at java.rmi.server.RemoteObjectInvocationHandler.invo keRemoteMethod(Unknown Source)
    at java.rmi.server.RemoteObjectInvocationHandler.invo ke(Unknown Source)
    at $Proxy0.moveAgentReceive(Unknown Source)
    at BESA.SystemLevel.AdmBESA.moveAgent(AdmBESA.java:28 5)
    at Monitor.GuardSolicitarT.funcExecGuard(GuardSolicit arT.java:33)
    at BESA.Agent.BehaviorBESA.run(BehaviorBESA.java:80)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.NotSerializableException: java.io.PrintWriter
    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    at java.io.ObjectOutputStream.defaultWriteFields(Unkn own Source)
    at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
    at java.io.ObjectOutputStream.writeOrdinaryObject(Unk nown Source)
    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    at sun.rmi.server.UnicastRef.marshalValue(Unknown Source)

    im working in a class that extends another class that implements serializable (io), and the kind of data is String, but the error or serializable is there.

    i have tried to put the data static, but the data changes to "NEW"

    what can i do for fix this serializable problem?

    thanks

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    if you have the property in your class that has the PrintWriter type, then try declaring this property as 'transient'. Transient properties are not attempted to be serialized.

    Though this usually means you will need to implement your own readObject() to have it set up this property after the object is de-serialized. for example, perhaps PrintWriter is the System.out. or a File output stream kind of thing. How should that get re-initialized after the object has been serialized. I mean, fixing serialization to not try to serialize this object reference to that resource will fix serialization, but without also re-establishing what that object is after deserializing it, the application will still likely have problems.

  3. #3
    yolimau is offline Member
    Join Date
    May 2010
    Posts
    8
    Rep Power
    0

Similar Threads

  1. Serialization
    By twiggy62 in forum New To Java
    Replies: 2
    Last Post: 02-12-2010, 05:45 AM
  2. Serialization
    By thayalan in forum Advanced Java
    Replies: 4
    Last Post: 08-03-2009, 11:22 PM
  3. Serialization
    By vijay24805 in forum Threads and Synchronization
    Replies: 1
    Last Post: 04-10-2009, 10:16 PM
  4. about serialization
    By bishnu in forum New To Java
    Replies: 0
    Last Post: 12-19-2008, 10:13 AM
  5. Replies: 0
    Last Post: 04-04-2008, 03:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •