SWF in JSF 2.2 causes java.lang.NullPointerException at com.sun.faces.application.NavigationHandlerImpl.determineViewFromActionOutcome

两盒软妹~` 提交于 2019-12-11 09:16:49

问题


I've a JSF 2.2 + Spring WebFlow application. When the below command button is pressed

<h:commandButton value="Aggiungi" action="#{pageController.modifica}" /> 

the following action is invoked

public String modifica() {
    // ...
    return "gest";
}

and the following navigation case needs to be resolved

<navigation-case>
    <from-action>#{pageController.modifica}</from-action>
    <from-outcome>gest</from-outcome>
    <to-view-id>/newxhtml.xhtml</to-view-id>
    <redirect />
</navigation-case>

the following exception is being thrown

java.lang.NullPointerException
    at com.sun.faces.application.NavigationHandlerImpl.determineViewFromActionOutcome(NavigationHandlerImpl.java:1204)
    at com.sun.faces.application.NavigationHandlerImpl.findExactMatch(NavigationHandlerImpl.java:568)
    at com.sun.faces.application.NavigationHandlerImpl.getViewId(NavigationHandlerImpl.java:462)
    at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:189)
    at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:182)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:132)
    at org.springframework.faces.webflow.FlowActionListener.processAction(FlowActionListener.java:71)
    at org.springframework.faces.model.SelectionTrackingActionListener.processAction(SelectionTrackingActionListener.java:55)
    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)
    ... 63 more

How is this caused and how can I solve it?


I increased spring flow-web to version 2.4.0 but I have the same error. Perhaps there are other inconsistencies in the list of jar in the library. Here is the complete list:

19/02/2015  17.44             4.467 aopalliance-1.0.jar
19/02/2015  17.44           304.373 commons-fileupload-1.3-javadoc.jar
19/02/2015  17.44            86.398 commons-fileupload-1.3-sources.jar
19/02/2015  17.44            36.475 commons-fileupload-1.3-test-sources.jar
19/02/2015  17.44            49.314 commons-fileupload-1.3-tests.jar
19/02/2015  17.44            67.986 commons-fileupload-1.3.jar
19/02/2015  17.44            62.050 commons-logging-1.1.3.jar
19/02/2015  17.44             2.497 javax.inject-1.jar
19/02/2015  17.44           634.222 jsf-api-2.1.7.jar
19/02/2015  17.44         1.962.213 jsf-impl-2.1.7.jar
19/02/2015  17.44           100.636 jsp-api-2.1.jar
19/02/2015  17.44           414.240 jstl-1.2.jar
19/02/2015  17.44           954.038 mysql-connector-java-5.1.30.jar
19/02/2015  17.44           592.322 postgresql-9.3-1102.jdbc41.jar
19/02/2015  17.44         1.824.331 primefaces-3.5.jar
19/02/2015  19.04                 0 print.txt
19/02/2015  17.44           105.112 servlet-api-2.5.jar
19/02/2015  17.44            29.868 smoothness-1.0.10.jar
19/02/2015  17.44           337.694 spring-aop-3.2.8.RELEASE.jar
19/02/2015  17.44           612.569 spring-beans-3.2.8.RELEASE.jar
19/02/2015  17.44           148.444 spring-binding-2.3.2.RELEASE.jar
19/02/2015  17.44           866.273 spring-context-3.2.8.RELEASE.jar
19/02/2015  17.44           873.608 spring-core-3.2.8.RELEASE.jar
19/02/2015  17.44           196.367 spring-expression-3.2.8.RELEASE.jar
19/02/2015  17.44           194.947 spring-faces-2.3.2.RELEASE.jar
19/02/2015  17.44           405.717 spring-jdbc-3.2.8.RELEASE.jar
19/02/2015  17.44            17.381 spring-js-2.3.2.RELEASE.jar
19/02/2015  17.44         4.412.472 spring-js-resources-2.3.2.RELEASE.jar
19/02/2015  17.44            83.412 spring-security-acl-3.2.3.RELEASE.jar
19/02/2015  17.44           406.536 spring-security-config-3.2.3.RELEASE.jar
19/02/2015  17.44           359.633 spring-security-core-3.2.3.RELEASE.jar
19/02/2015  17.44           342.300 spring-security-web-3.2.3.RELEASE.jar
19/02/2015  17.44           242.436 spring-tx-3.2.8.RELEASE.jar
19/02/2015  17.44           628.456 spring-web-3.2.8.RELEASE.jar
19/02/2015  17.44           565.416 spring-webflow-2.4.0.RELEASE.jar
19/02/2015  17.44           637.903 spring-webmvc-3.2.8.RELEASE.jar

Updating (02/26/2015) I did many tests and I finally changed the list of libraries and configuration files but, unfortunately, I still have the same error (with same trace).

Here is the new list of libraries

aopalliance-1.0.jar
commons-fileupload-1.3-javadoc.jar
commons-fileupload-1.3-sources.jar
commons-fileupload-1.3-test-sources.jar
commons-fileupload-1.3-tests.jar
commons-fileupload-1.3.jar
commons-logging-1.1.3.jar
javax.inject-1.jar
jsf-api-2.1.7.jar
jsf-api-2.2.0-m03.jar
jsf-impl-2.1.7.jar
jsf-impl-2.2.0.jar
jsp-api-2.1.jar
jstl-1.2.jar
mysql-connector-java-5.1.30.jar
org.springframework.binding-2.0.5.RELEASE.jar
postgresql-9.3-1102.jdbc41.jar
primefaces-3.5.jar
servlet-api-2.5.jar
smoothness-1.0.10.jar
spring-aop-3.2.6.RELEASE.jar
spring-beans-4.0.2.RELEASE.jar
spring-binding-2.4.0.RELEASE.jar
spring-context-4.0.2.RELEASE.jar
spring-core-4.0.2.RELEASE.jar
spring-expression-4.0.2.RELEASE.jar
spring-faces-2.3.1.RELEASE.jar
spring-jdbc-4.0.2.RELEASE.jar
spring-js-2.4.0.RELEASE.jar
spring-js-resources-2.4.0.RELEASE.jar
spring-jsf.jar
spring-orm-4.0.2.RELEASE.jar
spring-security-config-3.2.3.RELEASE.jar
spring-security-core-3.2.0.RELEASE.jar
spring-security-taglibs-3.2.3.RELEASE.jar
spring-security-web-3.2.3.RELEASE.jar
spring-tx-4.0.2.RELEASE.jar
spring-web-4.0.2.RELEASE.jar
spring-webflow-2.3.2.RELEASE.jar
spring-webflow-2.4.0.RELEASE.jar
spring-webmvc-4.0.2.RELEASE.jar
spring-webmvc-portlet-4.0.2.RELEASE.jar

There seems to be an incompatibility between libraries.


回答1:


This is caused by the combination Spring WebFlow 2.3.x and JSF 2.2. You need to upgrade Spring WebFlow to a JSF 2.2 compatible version, which is at least 2.4.x.

The technical problem is, SWF 2.3.x used an Application implementation which didn't properly extend from javax.faces.application.ApplicationWrapper and thus it had to manually implement/delegate all Application methods to the wrapped application. In case of SWF 2.3.x, all those methods were based on JSF 2.1. In JSF 2.2, a new method getFlowHandler() was added to Application, which wasn't properly delegated by SWF and thus returned null, causing all the trouble further down in the chain relying on it not being null. If SWF guys had properly extended from ApplicationWrapper instead of hardcoding all delegate methods for a specific JSF version, then it would flawlessly have worked through JSF versions.

See also:

  • Adding OmniFaces to JSF 2.2 with Weld app gives NullPointerException (exactly same problem with Weld)
  • faces-config with from-outcome not being string (boolean) fails with NullPointerException (exactly same problem with Seam)


来源:https://stackoverflow.com/questions/28605401/swf-in-jsf-2-2-causes-java-lang-nullpointerexception-at-com-sun-faces-applicatio

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