0
votes

We have a problem with Spring-webflow configuration and view redirection.

Upon login, you should enter the configured home page, but you are left in a redirect loop to the error page.

Checking the log traces, it is verified that when you submit in the login, it redirects to the corresponding view, but an error occurs with the spring component that controls the views and that only allows jsp and jspx.

We are working with Spring-webflow 2.4.1, Spring-mvc 3.1.4, jsf 2.2 and primefaces 4.0.

We have been verifying the different ways of how to do it with xml since it is an old application and what we are doing is refactoring from ant to maven in order to proceed with the modifications that are required.

The error that is generated is the following:

11:15:32,603 INFO [stdout] (http-localhost/127.0.0.1:8080-5) 10-06-2020 11:15:32,602 [DEBUG] [http-localhost/127.0.0.1:8080-5] [org.springframework.webflow.engine.impl.FlowExecutionImpl] Attempting to handle [org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'index' of flow 'start-flow'] with root cause [java.lang.IllegalArgumentException: Unsupported view type /WEB-INF/index.xhtml only types supported by this FlowViewResolver implementation are [.jsp] and [.jspx]] 11:15:32,603 ERROR [com.axa.ca.caem.web.core.exception.CaemExceptionHandler] (http-localhost/127.0.0.1:8080-5) Handling exception 11:15:32,603 INFO [stdout] (http-localhost/127.0.0.1:8080-5) 10-06-2020 11:15:32,603 [ERROR] [http-localhost/127.0.0.1:8080-5] [com.axa.ca.caem.web.core.exception.CaemExceptionHandler] Handling exception 11:15:32,604 ERROR [com.axa.ca.caem.web.core.exception.CaemExceptionHandler] (http-localhost/127.0.0.1:8080-5) Unknown error captured in CaemExceptionHandler: java.lang.IllegalArgumentException: Unsupported view type /WEB-INF/index.xhtml only types supported by this FlowViewResolver implementation are [.jsp] and [.jspx] at org.springframework.webflow.mvc.builder.FlowResourceFlowViewResolver.getViewInternal(FlowResourceFlowViewResolver.java:94) [spring-webflow-2.4.1.RELEASE.jar:2.4.1.RELEASE]

The configuration files are: spring-webflow.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:webflow="http://www.springframework.org/schema/webflow-config"
    xmlns:faces="http://www.springframework.org/schema/faces"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/webflow-config
        http://www.springframework.org/schema/webflow-config/spring-webflow-config.xsd
        http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces.xsd">

    <faces:resources/>

    <!-- Maps request paths to flows in the flowRegistry; localeChangeInterceptor 
    is used for intercepting internationalization changes -->
    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property name="flowRegistry" ref="flowRegistry" />
        <property name="interceptors">
            <list>
                <ref bean="localeChangeInterceptor"></ref>
            </list>
        </property>
        <property name="order" value="0"/>
    </bean>

    <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor" />
    </bean>

    <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
        <webflow:flow-execution-listeners>
            <webflow:listener ref="facesContextListener"/>
            <webflow:listener ref="securityListener"/>
        </webflow:flow-execution-listeners>
    </webflow:flow-executor> 

    <!-- Registramos todos nuestros flujos con la dupla id-xml -->
    <webflow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows">  
        <webflow:flow-location-pattern value="/**.xml" />
        <webflow:flow-location id="parent-flow" path="parent-flow.xml" />
    </webflow:flow-registry>  

    <webflow:flow-builder-services id="flowBuilderServices" />  

    <!-- Mapea a nombres logicos de vista to recursos fisicos -->
    <!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' to '/WEB-INF/search.xhtml' -->
    <bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".xhtml" />
    </bean>

    <!-- A listener to create and release a FacesContext -->
    <bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>

</beans>

Thanks in advance.

1

1 Answers

0
votes

This is the correct configuration for me. Thansk!

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:webflow="http://www.springframework.org/schema/webflow-config"
   xmlns:faces="http://www.springframework.org/schema/faces"
   xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/webflow-config
        http://www.springframework.org/schema/webflow-config/spring-webflow-config.xsd
        http://www.springframework.org/schema/faces 
        http://www.springframework.org/schema/faces/spring-faces.xsd">

    <faces:resources/>

    <!-- Spring Webflow central configuration component -->
    <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
        <webflow:flow-execution-listeners>          
            <webflow:listener ref="facesContextListener"/>          
            <webflow:listener ref="securityListener"/>
        </webflow:flow-execution-listeners>
    </webflow:flow-executor>

    <!-- Installs a listener that creates and releases the FacesContext for each request. -->   
    <bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>   

    <webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices" 
        base-path="/WEB-INF/flows/" >
        <webflow:flow-location-pattern value="/**.xml" />
        <webflow:flow-location id="parent-flow" path="parent-flow.xml" />
    </webflow:flow-registry>

    <!-- Configures the Spring Web Flow JSF integration --> 
    <faces:flow-builder-services id="facesFlowBuilderServices" development="true" />

    <bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
        <property name="viewResolvers">
            <list>
                <ref bean="viewResolver"/>
            </list>
        </property>     
    </bean>

    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver">
          <property name="prefix" value="/WEB-INF/views/"/>
          <property name="suffix" value=".xhtml" />
    </bean>

    <!-- Dispatches requests mapped to flows to FlowHandler implementations --> 
    <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">      
        <property name="flowExecutor" ref="flowExecutor" /> 
    </bean>

    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property name="flowRegistry" ref="flowRegistry"/>
        <property name="order" value="1"/>
    </bean>

</beans>