我正在从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]
答案 0 :(得分:0)
如果您尝试从视图范围bean访问数据,请尝试通过调用页面预渲染事件上的方法来加载数据bean。