1 2 Previous Next 17 Replies Latest reply: Apr 18, 2012 4:39 AM by Steve Hostettler RSS

Producer Method and java.io.NotSerializableException

Steve Hostettler Newbie

Hello,

 

There is something that I can really understand in my project. I get a java.io.NotSerializableException exception when Tomcat shuts down.

 

 

WARNING: Cannot serialize session attribute org.jboss.weld.context.ConversationContext.1#org.jboss.weld.bean-flat-ManagedBean-class ch.demo.web.ManageStudentRegistration for session 91DA3D803BD3BC86DCF7C5FF6BF6F942
java.io.NotSerializableException: java.util.logging.Logger
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
          at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
          at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:{1483)

 

 

My managed bean has a logger field which is transient:

 

 

@Named
@ConversationScoped
public class ManageStudentRegistration implements Serializable {

 private static final long serialVersionUID = 2123342218792192804L; 
 @Inject
 private transient Logger mLogger;
...

 

 

 

The producer for the logger looks like:

 

 

public class LoggerProducer  implements Serializable {

    private static final long serialVersionUID = -7352371086416154400L;

    @Produces
    public Logger getLogger(final InjectionPoint injectionPoint) {
        return LoggerFactory.getLogger(injectionPoint.getBean().getBeanClass());
    }

}

 

 

 

I do not understand what field it tries to serializable as the mLogger is transient.

 

In debug mode I get the following output from ObjectOutputStream.writeObject:

 

Bean: Producer Method [Logger] with qualifiers [@Any @Default] declared as [[method] @Produces public ch.demo.helpers.LoggerProducer.getLogger(InjectionPoint)]; Instance: org.slf4j.impl.JDK14LoggerAdapter(ch.demo.web.ManageStudentRegistration); CreationalContext: org.jboss.weld.context.CreationalContextImpl@17e34309

 

 

Obviously the problem is in the producer not in the member field mLogger.

 

Did I miss something obvious?

 

Many thanks in advance for your help

1 2 Previous Next