JPython and serialization

jpersson1 at yahoo.com jpersson1 at yahoo.com
Tue Sep 7 09:48:18 EDT 1999


Hello

Is there anyone out there who has experience with using
JPython together with the Java serialization API.

I want to subclass a native Java class in JPython
and then serialize an instance of this class to
a file, but when I try to do it I get the following error:

Traceback (innermost last):
  File "ser/test.py", line 11, in ?
java.io.NotSerializableException: org.python.core.PyFile$TextWrapper
        at java.io.ObjectOutputStream.outputObject
(ObjectOutputStream.java)
        at java.io.ObjectOutputStream.writeObject
(ObjectOutputStream.java)
        at java.io.ObjectOutputStream.defaultWriteObject
(ObjectOutputStream.java)
        at java.io.ObjectOutputStream.outputObject
(ObjectOutputStream.java)
        at java.io.ObjectOutputStream.writeObject
(ObjectOutputStream.java)
        at java.io.ObjectOutputStream.defaultWriteObject
(ObjectOutputStream.java)
        at java.io.ObjectOutputStream.outputObject
(ObjectOutputStream.java)
        at java.io.ObjectOutputStream.writeObject
(ObjectOutputStream.java)
        at java.io.ObjectOutputStream.defaultWriteObject
(ObjectOutputStream.java)
        at java.io.ObjectOutputStream.outputObject
(ObjectOutputStream.java)
        at java.io.ObjectOutputStream.writeObject
(ObjectOutputStream.java)
        at org.python.core.PyReflectedFunction.__call__
(PyReflectedFunction.java:156)
        at org.python.core.PyMethod.__call__(PyMethod.java:40)
        at org.python.core.PyObject.__call__(PyObject.java:268)
        at org.python.core.PyInstance.invoke(PyInstance.java:272)
        at org.python.pycode._pyx0.f$0(test.py)
        at org.python.pycode._pyx0.call_function(test.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:75)
        at org.python.core.Py.runCode(Py.java:935)
        at org.python.core.__builtin__.execfile(__builtin__.java:244)
        at org.python.core.__builtin__.execfile(__builtin__.java:248)
        at org.python.util.PythonInterpreter.execfile
(PythonInterpreter.java:132)
        at org.python.util.jpython.main(jpython.java:123)

java.io.NotSerializableException: java.io.NotSerializableException:
org.python.core.PyFile$TextWrapper

It seems that the JPython proxy class, that are created
on the fly when I am subclassing, contains references to
non serializable objects.

Can it be done or must I rethink my design?

--
Regards
  //Jan Persson (Syren Software, Sweden)


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list