转换'dataModel'时找不到面转换服务

时间:2009-10-20 07:41:21

标签: spring jsf spring-webflow

在使用JSF集成创建我的第一个swf应用程序时,我收到以下错误:在第一次请求解析我的流定义时无法加载类'dataModel'。

虽然我的webflow应用程序上下文中包含<faces:flow-builder-services/>标记,但是在尝试查找该别名的类时,似乎没有调用FacesConversionService(理解'dataModel'别名的类)。

在尝试找出原因时进行一些调试,我注意到以下内容:

  1. 上下文加载器侦听器加载包含<faces:flow-builder-services/>的xml文件,并注册facesConversionService bean
  2. 正确调用流处理程序映射和适配器,并将请求转发到预期的流,该定义是动态创建的。
  3. 在为流创建内部基础结构对象时,swf会在侦听器加载的应用程序上下文之上创建Web应用程序上下文。这个新的wac包含swf作用域的定义等,并且将上面的监听器应用程序上下文作为父级。
  4. 找到并解析了我的流的流定义文件,当它试图找到evaluate元素的结果类型的类时,转换服务不知道'dataModel'别名。
  5. 实际上,最后一点有趣的是转换服务要么在上面第3点创建的应用程序上下文中被查找为本地bean,要么在未找到 - 在父流构建器上下文中查找

    faces转换服务既不是上下文的本地bean(它在流上下文的父上下文中注册),也不是注册为流构建器上下文的转换服务(至少是创建的FlowBuilderContextImpl)通过<flow:flow-registry/>元素。)

    有人知道出了什么问题吗?

    我不认为它与应用程序服务器有关,但为了以防万一,我在websphere 6.1.0.23上运行,使用spring 2.5.6和webflow 2.0.8.RELEASE。

    以下是我的配置文件:

    的web.xml:

    <listener>
      <listener-class>
        org.springframework.web.context.ContextLoaderListener
      </listener-class>
    </listener>
    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext-*.xml</param-value>
    </context-param>
    ...
    <servlet>
      <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet
      <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
      <url-pattern>/swf/*</url-pattern>
    </servlet-mapping>
    

    MVC部分的Bean定义(/WEB-INF/applicationContext-webmvc.xml):

    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
      <property name="flowRegistry" ref="flowRegistry" />
      <property name="defaultHandler">
        <bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
      </property>
    </bean>
    
    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
      <property name="flowExecutor" ref="flowExecutor" />
    </bean>
    
    <bean id="faceletsViewResolver" 
      class="org.springframework.web.servlet.view.UrlBasedViewResolver">
      <property name="viewClass" value="org.springframework.faces.mvc.JsfView" />
      <property name="prefix" value="/WEB-INF/" />
      <property name="suffix" value=".jspx" />
    </bean>
    
    <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
    

    swf部分的Bean定义(/WEB-INF/applicationContext-webflow.xml):

    <flow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows">
      <flow:flow-location path="/navigation/navigation.xml"/>
      <flow:flow-location path="/edition/edition.xml"/>
    </flow:flow-registry>
    
    <flow:flow-executor id="flowExecutor">
      <flow:flow-execution-listeners>
          <flow:listener ref="jpaFlowExecutionListener" criteria="edition"/>
      </flow:flow-execution-listeners>
    </flow:flow-executor>
    
    <faces:flow-builder-services id="facesFlowBuilderServices" development="true"/>
    
    <bean id="jpaFlowExecutionListener" 
            class="org.springframework...JpaFlowExecutionListener">
      <constructor-arg ref="entityManagerFactory" />
      <constructor-arg ref="transactionManager" />
    </bean>
    

    异常的堆栈跟踪:

    [Servlet Error]-[Spring MVC Dispatcher Servlet]: java.lang.IllegalArgumentException: Unable to load class 'dataModel'                                                                
     at org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder.toClass(FlowModelFlowBuilder.java:965)                                                                    
     at org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder.parseEvaluationActionResultExposer(FlowModelFlowBuilder.java:867)                                         
     at org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder.parseEvaluateAction(FlowModelFlowBuilder.java:858)                                                        
     at org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder.parseActions(FlowModelFlowBuilder.java:834)                                                               
     at org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder.parseAndAddViewState(FlowModelFlowBuilder.java:547)                                                       
     at org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder.buildStates(FlowModelFlowBuilder.java:207)                                                                
     at org.springframework.webflow.engine.builder.FlowAssembler.directAssembly(FlowAssembler.java:106)                                                                                 
     at org.springframework.webflow.engine.builder.FlowAssembler.assembleFlow(FlowAssembler.java:91)                                                                                    
     at org.springframework.webflow.engine.builder.DefaultFlowHolder.assembleFlow(DefaultFlowHolder.java:109)                                                                           
     at org.springframework.webflow.engine.builder.DefaultFlowHolder.getFlowDefinition(DefaultFlowHolder.java:84)                                                                       
     at org.springframework.webflow.definition.registry.FlowDefinitionRegistryImpl.getFlowDefinition(FlowDefinitionRegistryImpl.java:61)                                                
     at org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:138)                                                                                
     at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:193)                                                                                  
     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)                                                                                        
     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)                                                                                         
     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)                                                                                      
     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)                                                                                               
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
    

2 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,但这是因为我指定了自己的转化服务,该服务扩展了DefaultConversionService而不是FacesConversionService

答案 1 :(得分:0)

我忘了在flow上指定flow-builder-services属性:flow-registry element !!!现在工作得很好。

<flow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows" flow-builder-services="facesFlowBuilderServices">
   <flow:flow-location path="/navigation/navigation.xml"/>
   <flow:flow-location path="/edition/edition.xml"/>
</flow:flow-registry>

<faces:flow-builder-services id="facesFlowBuilderServices" development="true"/>