FlowScope getNavigationCaseFromFlowStructure空指针错误

时间:2019-07-03 15:55:22

标签: jsf-2.2 flow-scope

我有一个使用嵌入式tomcat的项目,我试图从外部页面输入流程,但是发生错误,我不知道该怎么解决。

这是我的结构:

index.xhtml
proxy/proxy-flow.xml
proxy/proxy.xhtml

尝试访问流时的错误是:

java.lang.NullPointerException: null
    at org.apache.myfaces.application.NavigationHandlerImpl.getNavigationCaseFromFlowStructure(NavigationHandlerImpl.java:904) ~[myfaces-impl-2.2.8.jar:2.2.8]
    at org.apache.myfaces.application.NavigationHandlerImpl.getNavigationCommand(NavigationHandlerImpl.java:719) ~[myfaces-impl-2.2.8.jar:2.2.8]
    at org.apache.myfaces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:134) ~[myfaces-impl-2.2.8.jar:2.2.8]
    at org.apache.myfaces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:122) ~[myfaces-impl-2.2.8.jar:2.2.8]
    at org.primefaces.application.DialogNavigationHandler.handleNavigation(DialogNavigationHandler.java:113) ~[primefaces-7.0.jar:7.0]
    at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:140) ~[myfaces-impl-2.2.8.jar:2.2.8]
    at org.primefaces.application.DialogActionListener.processAction(DialogActionListener.java:54) ~[primefaces-7.0.jar:7.0]
    at javax.faces.component.UICommand.broadcast(UICommand.java:120) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1172) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:365) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1658) ~[myfaces-api-2.2.8.jar:2.2.8]
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:862) ~[myfaces-api-2.2.8.jar:2.2.8]
    at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:42) ~[myfaces-impl-2.2.8.jar:2.2.8]
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:196) ~[myfaces-impl-2.2.8.jar:2.2.8]
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143) ~[myfaces-impl-2.2.8.jar:2.2.8]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198) ~[myfaces-api-2.2.8.jar:2.2.8]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at bns.scotiabank.filter.Myfilter.doFilter(Myfilter.java:42) ~[classes/:na]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) ~[tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1575) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1533) [tomcat-embed-core-8.0.3.jar:8.0.3]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_144]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_144]

Pom:

<modelVersion>4.0.0</modelVersion>

<groupId>bns.cardAccount</groupId>
<artifactId>consult</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<tomcat.version>8.0.3</tomcat.version>
<start-class>spring-boot-example.Application</start-class>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.apache.log4j.version>2.1</org.apache.log4j.version>
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
<org.hibernate.core.version>4.3.9.Final</org.hibernate.core.version>
<org.hibernate.entitymanager.version>4.3.9.Final</org.hibernate.entitymanager.version>
<org.hibernate.annotations.version>4.0.5.Final</org.hibernate.annotations.version>
<org.hibernate.jpa.version>1.0.0.Final</org.hibernate.jpa.version>

</properties>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<!--<version>1.4.0.RELEASE</version>-->
</parent>

<dependencies>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-logging-juli</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.2-GA</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--hibernate-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.9.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${org.hibernate.entitymanager.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>${org.hibernate.annotations.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>${org.hibernate.jpa.version}</version>
</dependency>
<dependency>
<groupId>com.sybase.jdbc4.jdbc</groupId>
<artifactId>jconn4</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>2.2.8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>2.2.8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>7.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.8</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>2.0.12.Final</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.5.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.12</version>
</dependency>
</project>

index.xhtml

    <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
      <f:metadata>
        <f:viewAction action="#{login.init}" />
      </f:metadata>
    <h:head>
        <title>-----</title>

    </h:head>
    <h:body> 
    <f:view>
<body class="align">

  <div class="grid">

    <div id="login">

      <h2><span class="fontawesome-lock"></span>Inicia Sesión</h2>


        <h:form>
        <fieldset>

          <p><h:commandButton value="Enter" action="proxy"/></p>

        </fieldset>
        </h:form>


    </div>

  </div>

</body> 
         </f:view>
    </h:body>
</html>

proxy / proxy-flow.xml

    <faces-config version="2.2" 
  xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
  http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">

   <application/>
   <flow-definition id="proxy">
    <flow-return id="returnFromProxyFlow">
    <start-node>proxy</start-node>
        <from-outcome>#{ProxyBean.regreso}</from-outcome>
    </flow-return>
</flow-definition>
</faces-config>

proxy / proxy.xhtml

    <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
      <f:view contentType="text/html">
    <h:head>
        </h:head>
        <h:body>

        <h:outputText value = "#{flowScope.valor}"/>
        </h:body>
</f:view>
        </html>

beans / ProxyBean

import javax.faces.flow.FlowScoped;
import javax.inject.Named;

@Named
@FlowScoped("proxy")
public class ProxyBean{
    private string valor = "hello";

    public String getValor(){
    return valor;
    }
}

请帮助我,我找不到答案的原因

1 个答案:

答案 0 :(得分:0)

尝试您的豆子 <h:outputText value = "#{proxyBean.valor}"/>

flowscope用于要将参数从一页传递到另一页