Eclipse
glassfish

GlassFishを起動しようとしたら WELD-000072: Bean declaring a passivating scope must be passivation capable.となってしまった時の対応方法

More than 1 year has passed since last update.

環境
OS : 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)
    at org.jboss.weld.bootstrap.BeanDeployer.doAfterBeanDiscovery(BeanDeployer.java:343)
    at org.jboss.weld.bootstrap.BeanDeployment.afterBeanDiscovery(BeanDeployment.java:271)
    at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:432)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:222)
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:496)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
    at java.lang.Thread.run(Thread.java:748)
]]

原因 : バッキングビーンに@SessionScopedを使っているのにSerializableを実装していないから

修正前
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";

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

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