I'm using JDK 1.4.1, and Tomcat 4.1.24.

I was seeing a strange situation where some cactus/ant tests of mine
would succeed on one run, and then fail on the next, and alternate in
that pattern continuously.

After looking carefully at the Tomcat logs, I discovered that a class
that is instantiated and then put into the session has a Log4J Logger
object.  Tomcat tries to persist that session, but it fails because
Logger is not serializable.

If I want to allow objects of this class to be serialized and
deserialized, how do I deal with the contained Logger object?

The class presently defines it's "logger" instance variable like this:

        protected final Logger logger =
Logger.getLogger(this.getClass());

Do I instead have to make this "transient" and change all the references
to the "logger" instance variable to call an accessor which tries to
initialize the value first if it's null?  Or perhaps do I have to add
"writeObject()" and "readObject()" methods where the "writeObject()"
method specifically writes all the fields but this one, and the
"readObject()" method reads all those fields, and then manually sets the
"logger" value?



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to