passivating scope must be passivation capable and bean is not proxyable
nimo22 Aug 31, 2010 4:26 AMI have this bean:
import java.util.List; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.enterprise.context.SessionScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.slf4j.Logger; @SessionScoped @Named public class MyBean{ @Inject private Logger log; @PersistenceContext EntityManager entityManager; @PostConstruct public void initialize() { log.info("@PostConstruct"); log.info("{} was created.", this.getClass().getSimpleName()); } @PreDestroy public void preDestroy() { log.info("@PreDestroy"); log.info("{} was destroyed.", this.getClass().getSimpleName()); } .. }
and it returns this error:
WELD-000072 Managed bean declaring a passivating scope must be passivation capable. Bean: org.jboss.weld.bean-flat-ManagedBean-class com.MyBean
The first question is:
Does MyBean declares a passivating scope? Where? How can I undeclare it?
I have not explicitly declared
@NormalScope(passivating=true)
According to JSR-299-Specification chapter 6.6.3. Passivating scopes:
For example, the built-in session and conversation scopes defined in Section 6.7, “Context management for built-in
scopes” are passivating scopes. No other built-in scopes are passivating scopes.
So MyBean is SessionScoped, hence it implicitly declares
@NormalScope(passivating=true)
Am I right?
And so I have to implement Serializable for all these kinds of beans:
- sessionScoped ManagedBeans
- conversationScoped ManagedBeans
- statefull (EJB)SessionBeans
Am I right?
The second question is:
After that deployement error, I have changed MyBean to implement Serializable:
@SessionScoped @Named public class MyBean{ implements Serializable{ private static final long serialVersionUID = -2564031884483676327L; ..}
And another deployement-error is coming:
org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001400 Normal scoped bean org.jboss.weld.bean-flat-ManagedBean-class com.MyBean is not proxyable
You see, MyBean is really a simple bean and CDI returns one error to another.
What is wrong?
I am using JBOSS 6 M4, its actual CDI-Implementation, JPA 2, JSF 2.