我正在从Myfaces 1.2升级到Myfaces 2.2。
我遇到了一个问题,当bean值由于bean的重新初始化而丢失时。因此,我尝试将bean的范围从请求范围更改为视图范围,但我得到以下错误。
控制台错误:-
java.lang.NullPointerException
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver$5.put(ManagedBeanResolver.java:101) [myfaces-impl-2.2.2.jar]
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.putInScope(ManagedBeanResolver.java:367) [myfaces-impl-2.2.2.jar]
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.createManagedBean(ManagedBeanResolver.java:340) [myfaces-impl-2.2.2.jar]
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.getValue(ManagedBeanResolver.java:296) [myfaces-impl-2.2.2.jar]
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67) [el-api.jar:2.2.FR]
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:179) [myfaces-impl-2.2.2.jar]
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72) [jasper-el.jar:7.0.39]
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) [jasper-el.jar:7.0.39]
at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:77) [myfaces-impl-2.2.2.jar]
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:184) [myfaces-impl-2.2.2.jar]
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143) [myfaces-impl-2.2.2.jar]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198) [myfaces-api-2.2.2.jar]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) [catalina.jar:7.0.39]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.39]
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349) [tomahawk20-1.1.10.jar]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) [catalina.jar:7.0.39]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.39]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) [catalina.jar:7.0.39]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) [catalina.jar:7.0.39]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) [catalina.jar:7.0.39]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) [catalina.jar:7.0.39]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) [catalina.jar:7.0.39]
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947) [catalina.jar:7.0.39]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.39]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) [catalina.jar:7.0.39]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009) [tomcat-coyote.jar:7.0.39]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) [tomcat-coyote.jar:7.0.39]
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) [tomcat-coyote.jar:7.0.39]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [1.6.0_35]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [1.6.0_35]
at java.lang.Thread.run(Thread.java:662) [1.6.0_35]
如果您试图从视图作用域bean访问数据,请尝试通过调用页面预呈现事件的方法来加载数据bean。