470,833 Members | 1,956 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

java.io.NotActiveException

I have a class, Environment that implements java.io.Serializable and it
has a method public boolean store(java.io.File) that calls
java.io.ObjectOutputStream.defaultWriteObject() but when I do:

Environment e = new Environment();
e.store(...);

It raises java.io.NotActiveException. Can someone please explain this
and tell me how to get rid of it? Thanks!

Jul 17 '05 #1
1 4752
Sherrod Faulks <bi****@verizon.net> wrote in news:2004082615122316807%
birded@verizonnet:
I have a class, Environment that implements java.io.Serializable and it
has a method public boolean store(java.io.File) that calls
java.io.ObjectOutputStream.defaultWriteObject() but when I do:

Environment e = new Environment();
e.store(...);

It raises java.io.NotActiveException. Can someone please explain this
and tell me how to get rid of it? Thanks!

The javadocs are your friend! They are available online, or can be
downloaded and installed on your computer.

From the javadoc for method defaultWriteObject of class ObjectOutputStream:
================================================== =========================
defaultWriteObject
public void defaultWriteObject()
throws IOExceptionWrite
the non-static and non-transient fields of the current class to this
stream. This may only be called from the writeObject method of the class
being serialized. It will throw the NotActiveException if it is called
otherwise.

Throws:
IOException - if I/O errors occur while writing to the underlying
OutputStream
================================================== =========================
Note the statement "This may only be called from the writeObject method of
the class being serialized. " Your call is violating this rule.

Why are you calling defaultWriteObject instead of calling writeObject ?

--
Ian Shef
These are my personal opinions and not those of my employer.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Michael | last post: by
reply views Thread by Ravi Tallury | last post: by
1 post views Thread by ptaz | last post: by
reply views Thread by Markus Wollny | last post: by
oll3i
reply views Thread by oll3i | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.