WELD-000072 Managed bean declaring a passivating scope must be passivation capable
Asked Answered
H

7

102

I wrote a simple program in java web forms but i am receiving the following error:

WELD-000072 Managed bean declaring a passivating scope must be passivation capable. Bean: Managed Bean [class BeanPakage.DemoBeans] with qualifiers [@Any @Default @Named]

Can anyone tell me where this error comes from?

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;


@Named("DemoBeans")
@SessionScoped
public class DemoBeans {

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
Hic answered 18/3, 2012 at 17:21 Comment(0)
P
194

You can make your bean passivation capable by implementing the Serializable interface:

public class DemoBean implements Serializable { ... }

Note that there are more requirements for being passivation capable. Refer to the Weld documentation for more information.

Purkey answered 18/3, 2012 at 17:37 Comment(0)
C
22

The error might remain even though the CDI bean is serializable:

WELD-000072 Managed bean declaring a passivating scope must be passivation capable

Example class:

@Named
@ConversationScoped
public class TransactionMatchController implements Serializable {
    ...
}

Make sure that all @Interceptors are seializable as well:

@Interceptor
@Transactional
public class TransactionInterceptor implements Serializable {
    ...
}
Childish answered 31/8, 2012 at 12:52 Comment(1)
Thanks, serializable @Interceptors was the problem for me !Imbed
S
6

It must be serializable.

See this answer.

https://community.jboss.org/thread/179828

Best, Anders

Savannahsavant answered 18/3, 2012 at 17:34 Comment(0)
Q
6

Make DemoBeans serialized

@Named("DemoBeans")
@SessionScoped
public class DemoBeans  implements Serializable
{

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
Quadrature answered 7/12, 2012 at 3:49 Comment(0)
A
2

You can also activate passivation behavior of your bean with the annotation:

@Stateful(passivationCapable=true)

In this case you don't need to implement Serializable interface.

Regards. Jorge

Alanis answered 5/11, 2015 at 13:43 Comment(0)
S
0

Verify imports

(some times netbeans used others from others libraries)

Example. import javax.faces.view.ViewScoped; change it by import javax.faces.bean.ViewScoped;

Secern answered 23/5, 2017 at 2:18 Comment(1)
Actually JSF 2.3 deprecates javax.faces.bean.ViewScoped in favour to javax.faces.view.ViewScoped. Does this mean I have to go through all my view scoped beans and make them serializable? From the javax.faces.bean.ViewScoped javadoc: @deprecated This has been replaced by {@code javax.faces.view.ViewScoped}. The functionality of this corresponding annotation is identical to this one, but it is implemented as a CDI custom scope.Lusitania
G
0

Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-000072: Bean declaring a passivating scope must be passivation capable. Bean: Managed Bean [class com.marcos.controller.PersonaBean] with qualifiers [@Default @Named @Any]


I solved it, apparently CDI,I did not recognize the bean, I just made it more explicit

@Named
@ViewScoped
public class PersonaBean  implements Serializable {
@Inject
private IPersonaService service;
public void registrar() {

    try {
        service.registrar(null);

    }catch (Exception e) {
        e.printStackTrace();
    }
  }
}

the solution for me:

@Named ("PersonaBean")
@ViewScoped
public class PersonaBean  implements Serializable {
@Inject
private IPersonaService service;
public void registrar() {

    try {
        service.registrar(null);

    }catch (Exception e) {
        e.printStackTrace();
    }
  }
}
Gilthead answered 21/2, 2018 at 4:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.