h:commandButton のナビゲーションで ViewScope の問題が発生しています。JSF 2.2 が CDI 1.0 でサポートされているかどうかわかりません
エラー
May 28, 2020 5:57:07 PM com.sun.faces.context.ExceptionHandlerImpl throwIt
INFO: Exception when handling error trying to reset the response.
java.lang.NullPointerException
at com.sun.faces.application.view.ViewScopeContextManager.destroyBeans(ViewScopeContextManager.java:171)
at com.sun.faces.application.view.ViewScopeContextManager.clear(ViewScopeContextManager.java:122)
at com.sun.faces.application.view.ViewScopeManager.processPreDestroyViewMap(ViewScopeManager.java:335)
at com.sun.faces.application.view.ViewScopeManager.processEvent(ViewScopeManager.java:240)
at com.sun.faces.application.view.ViewScopeEventListener.processEvent(ViewScopeEventListener.java:68)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108)
at javax.faces.event.ComponentSystemEvent.processListener(ComponentSystemEvent.java:118)
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2169)
at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2142)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:294)
at javax.faces.component.UIViewRoot$ViewMap.clear(UIViewRoot.java:1850)
at com.sun.faces.application.NavigationHandlerImpl.clearViewMapIfNecessary(NavigationHandlerImpl.java:432)
at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:249)
at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:183)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:132)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Tomcat 8.5環境での最小限の再現可能な例 test.xhtml -> 「ajax working」ボタンが機能し、「h:commandButton non-ajax」ボタンが失敗
- Mojarra バージョン jsf-api-2.2.13 および jsf-impl-2.2.13 で失敗する
- Mojarra バージョン javax.faces-2.2.20 で失敗する
- myfaces バージョン myfaces-api-2.2.12 および myfaces-impl-2.2.12 で動作します
- omnifaces バージョン omnifaces-1.8.3 org.omnifaces.cdi.ViewScoped で動作します (追加の jar validation-api-1.1.0.Final を追加する必要がありました)
TestView.java
package com.lean.demo;
import java.io.Serializable;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
@Named
@ViewScoped
public class TestView implements Serializable {
public String goNextCase1() {
System.out.println("goNextCase1");
// Add navigation-case with <redirect />
return "PageTestView2";
}
public String goNextCase2() {
System.out.println("goNextCase2");
return "test2.xhtml?faces-redirect=true";
}
public String goNextCase3() {
System.out.println("goNextCase3");
return "test2.xhtml";
}
}
test.xhtml
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Mojarra JSF 2.2 with openwebbeans 1.1.0 (CDI 1.0)</title>
</h:head>
<h:body>
<h:form id="frmTest">
<h2>
<h:commandButton value="Case 1" action="#{testView.goNextCase1()}">
</h:commandButton>
</h2>
<h2>
<h:commandButton value="Case 2" action="#{testView.goNextCase2()}">
</h:commandButton>
</h2>
<h2>
<h:commandButton value="Case 3" action="#{testView.goNextCase3()}">
</h:commandButton>
</h2>
</h:form>
</h:body>
</html>
リブの瓶
commons-beanutils-1.9.2.jar
commons-collections-3.2.2.jar
commons-digester-1.8.jar
commons-logging-1.1.1.jar
geronimo-atinject_1.0_spec-1.0.jar
geronimo-interceptor_1.1_spec-1.0.jar
geronimo-jcdi_1.0_spec-1.0.jar
javassist-3.12.0.GA.jar
jsf-api-2.2.13.jar
jsf-impl-2.2.13.jar
openwebbeans-impl-1.1.0.jar
openwebbeans-jsf-1.1.0.jar
openwebbeans-resource-1.1.0.jar
openwebbeans-spi-1.1.0.jar
openwebbeans-web-1.1.0.jar
scannotation-1.0.2.jar