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

JavaCdiJboss Weld

Java Problem Overview


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;
    }
}

Java Solutions


Solution 1 - Java

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.

Solution 2 - Java

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 {
    ...
}

Solution 3 - Java

It must be serializable.

See this answer.

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

Best, Anders

Solution 4 - Java

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;
    }

}

Solution 5 - Java

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

Solution 6 - Java

Verify imports

(some times netbeans used others from others libraries)

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

Solution 7 - Java

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();
	}
  }
}


Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionchristinaView Question on Stackoverflow
Solution 1 - JavaMatt HandyView Answer on Stackoverflow
Solution 2 - JavaTimView Answer on Stackoverflow
Solution 3 - Javaanders.norgaardView Answer on Stackoverflow
Solution 4 - JavaMohd Kose AvaseView Answer on Stackoverflow
Solution 5 - JavaJorge TorresView Answer on Stackoverflow
Solution 6 - JavaFabian PisaniView Answer on Stackoverflow
Solution 7 - JavaMarcos Chacaliaza AltamiranoView Answer on Stackoverflow