-
1. Re: java.io.NotSerializableException: org.apache.log4j.Logge
cvandyck May 3, 2004 4:57 PM (in response to roger_cmu)Try declaring your logger as static. I believe log4j is multi-thread safe. This should prevent the container from trying to serialize your logger when it passivates your bean.
-
2. Re: java.io.NotSerializableException: org.apache.log4j.Logge
lviz May 4, 2004 10:02 AM (in response to roger_cmu)hi
also...
code:
private Logger logger = null
public void ejbActivate() {
logger = Logger.getLogger("cts.ejb.user.session."
+ getClass().getName());
logger.debug("ejbActivate");
}
public void ejbPassivate() {
logger.debug("ejbPassivate");
logger = null;
}
cheers L -
3. Re: java.io.NotSerializableException: org.apache.log4j.Logge
roger_cmu May 4, 2004 1:49 PM (in response to roger_cmu)Hi cvandyck,
Thanks for reply. Could you please elaborate on your answer. I thought any non-transiet field marked as not-null field will be passivated. As per your suggestion, it seems marking a field as 'static' will exempt that field from passivation. Does passivation treat static fields differently?
Thanks to Lviz too.
thanks.
- Roger -
4. Re: java.io.NotSerializableException: org.apache.log4j.Logge
wdfink May 5, 2004 3:20 AM (in response to roger_cmu)Hi raj_cmu,
static fields in a class means:
all instances of this class refere the same attribut.
In this case all instances of your bean use exactly the same Logger-instance!
It make no sense for an EntityBean to store this attribute in a storage ;-)
one word to
private static Logger ......
it make sense to declare
private static final Logger ....
Reason:
You will never change the Logger so you become a better Performance in your application when you use it thorough for this kind of attributes.
Wolf -
5. Re: java.io.NotSerializableException: org.apache.log4j.Logge
dannyyates May 5, 2004 3:53 AM (in response to roger_cmu)Roger, it's all in the specs. Neither transient nor static fields are serialized by the default serialization mechanism.