1

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

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

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

  1. 包含的 xml 文件<faces:flow-builder-services/>由上下文加载器侦听器加载,并且 facesConversionService bean 已注册
  2. 流处理程序映射和适配器被正确调用,请求被转发到预期的流,该流定义是动态创建的。
  3. 在为流创建内部基础结构对象时,swf 在侦听器加载的应用程序上下文之上创建一个 Web 应用程序上下文。这个新的 wac 包含对 swf 范围等的定义,并将上面的侦听器的应用程序上下文作为父级。
  4. 找到并解析了我的流程的流程定义文件,当它尝试查找评估元素的结果类型的类时,转换服务不知道“dataModel”别名。

实际上,最后一点的有趣之处在于,转换服务要么在上面第 3 点创建的应用程序上下文中查找为本地 bean,要么在父流构建器上下文中查找 - 如果未找到。

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

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

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

这是我的配置文件:

网页.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 部分的 Beans 定义(/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)
4

2 回答 2

0

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

于 2009-11-06T01:13:18.760 回答
0

我忘了在 flow:flow-registry 元素上指定 flow-builder-services 属性!!!现在完美运行。

<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"/>
于 2009-11-27T12:44:15.993 回答