3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WELD-000072: Bean declaring a passivating scope must be passivation capable.となってしまった時の対応方法

Last updated at Posted at 2017-12-02
  • 環境
    • MacOS Hight Sierra Version 10.13.1
    • Eclipse : Neon.3 Release (4.6.3) Build id: 20170314-1500
    • GlassFish : 4.1.2 (build 1)
    • JSF : 2.2

事象 : EclipseでGlassFishを起動したらエラーになった。

Screen Shot 2017-11-28 at 22.46.34.png

cannot Deploy アプリ名
deploy is failing=Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-000072: Bean declaring a passivating scope must be passivation capable.  Bean:  Managed Bean [class secondSubmittedValue.PasswordBean] with qualifiers [@Default @Any @Named]. Please see server.log for more details.
server.log
[2017-12-02T09:02:49.893+0900] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=45 _ThreadName=admin-listener(4)] [timeMillis: 1512172969893] [levelValue: 1000] [[
  Exception while loading the app]]

[2017-12-02T09:02:49.895+0900] [glassfish 4.1] [SEVERE] [AS-WEB-GLUE-00192] [javax.enterprise.web] [tid: _ThreadID=45 _ThreadName=admin-listener(4)] [timeMillis: 1512172969895] [levelValue: 1000] [[
  Undeployment failed for context /firstJsf]]

[2017-12-02T09:02:49.905+0900] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=45 _ThreadName=admin-listener(4)] [timeMillis: 1512172969905] [levelValue: 1000] [[
  Exception while loading the app : CDI deployment failure:WELD-000072: Bean declaring a passivating scope must be passivation capable.  Bean:  Managed Bean [class secondSubmittedValue.PasswordBean] with qualifiers [@Default @Any @Named]
org.jboss.weld.exceptions.DeploymentException: WELD-000072: Bean declaring a passivating scope must be passivation capable.  Bean:  Managed Bean [class secondSubmittedValue.PasswordBean] with qualifiers [@Default @Any @Named]
	at org.jboss.weld.bean.ManagedBean.checkType(ManagedBean.java:213)
	at org.jboss.weld.bean.AbstractBean.initializeAfterBeanDiscovery(AbstractBean.java:105)
	at org.jboss.weld.bean.ManagedBean.initializeAfterBeanDiscovery(ManagedBean.java:122)
...省略..

原因 : バッキングビーンに@RequestScoped以外のスコープを使っているのにSerializableを実装していないから

@RequestScoped以外はSerializableインタフェースを実装します

@RequestScoped以外のバッキングビーンは、必要に応じてメモリから記憶装置に退避されたり、逆に復元されたりします。
この時、メモリ上のオブジェクトをデータ化して保存するためには、Serializableインタフェースを実装しておく必要があります。
image.png

修正前
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

import lombok.Data;

@Named
@SessionScoped
@Data
public class PasswordBean {
    /** パスワード. */
    private String password = "password";

対応 : バッキングビーンにSerializableを実装する

修正後
import java.io.Serializable;

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

import lombok.Data;

@Named
@SessionScoped
@Data
public class PasswordBean implements Serializable {
    /** serialVersionUID. */
    private static final long serialVersionUID = 8156366672034041582L;
    /** パスワード. */
    private String password = "password";
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?