faces-config with from-outcome not being string (boolean) fails with NullPointerException

时光毁灭记忆、已成空白 提交于 2019-12-12 02:03:13

问题


I've been using JSF 2.1 with mojarra-2.1.20, and I've configured in my faces-config.xml a navigation case like this:

<navigation-rule>
    <from-view-id>/loggedOut.xhtml</from-view-id>
    <navigation-case>
        <from-action>#{sessionManager.isLoggedIn}</from-action>
        <from-outcome>true</from-outcome>
        <to-view-id>/login.xhtml</to-view-id>
        <redirect />
    </navigation-case>
</navigation-rule>

The action is executed using seam-faces viewAction (similiar to JSF 2.2 new tag). All has been working fine.

Today I've upgraded to JSF 2.2 with mojarra-2.2.6, and browsing to the view loggedOut.xhtml stoped working. It throws this stacktrace:

java.lang.NullPointerException
    at com.sun.faces.application.NavigationHandlerImpl.determineViewFromActionOutcome(NavigationHandlerImpl.java:1342)
    at com.sun.faces.application.NavigationHandlerImpl.findExactMatch(NavigationHandlerImpl.java:603)
    at com.sun.faces.application.NavigationHandlerImpl.getViewId(NavigationHandlerImpl.java:481)
    at com.sun.faces.application.NavigationHandlerImpl.getNavigationCase(NavigationHandlerImpl.java:149)
    at com.sun.faces.application.NavigationHandlerImpl.getNavigationCase(NavigationHandlerImpl.java:140)
    at org.jboss.seam.faces.event.SeamPreNavigationHandler.getNavigationCase(SeamPreNavigationHandler.java:42)
    at org.jboss.seam.faces.event.SeamPreNavigationHandler.handleNavigation(SeamPreNavigationHandler.java:57)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:132)
    at org.jboss.seam.faces.component.UIViewAction.broadcast(UIViewAction.java:381)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
    at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
    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:646)
    ...

I have more navigations like this, and all of them fail in the same way. The only difference between this navigations and other cases and examples is that from-outcome value is a boolean and not a String. So my questions are:

  • Should from-outcome's fail when it is not a String?
    • If so, should not fail with a more "readable" message?
    • Else, is a mojara bug?
  • Version 2.1 was wrong then?

I know how to "fix it": using a {dummyAction.execute} and checking the boolean in the <if> tag. But I prefered to execute the real action and not 2 differents.


回答1:


After posting @glassfish, and doing some testing and debugging, I found that the real cause is the deprecated thirdaparty CDI extension seam-faces.

As they extends the javax.faces.application.ApplicationWrapper, but the code is compiled against JSF 2.1, the method #getFlowHandler returns always null.



来源:https://stackoverflow.com/questions/23776638/faces-config-with-from-outcome-not-being-string-boolean-fails-with-nullpointer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!