错误嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException WebFlow

发布于 2024-12-06 22:17:12 字数 4967 浏览 2 评论 0原文

我在 jboss 7.0.1.FINAL 中使用 webflow 2.3.0.RELEASE 和 richfaces 4.0.0.Final 时遇到这样的错误:

12:16:46,989 INFO [stdout] (MSC 服务线程 1-7) 2011-09-20 12:16:46,987 [MSC 服务线程 1-7] 错误 (FrameworkServlet.java:314) ï¿初始化失败 12:16:46,989 INFO [stdout](MSC 服务线程 1-7) org.springframework.beans.factory.BeanCreationException:创建名称为“flowExecutor”的bean时出错:设置bean属性“flowExecutionListenerLoader”时无法创建[org.springframework.webflow.config.FlowExecutionListenerLoaderFactoryBean]类型的内部bean“(内部bean)”;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名称为“(inner bean)#1”的 bean 时出错:设置 bean 属性“listeners”时无法解析对 bean“jpaFlowExecutionListener”的引用;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建 ServletContext 资源 [/WEB-INF/spring/transportes-webflow.xml] 中定义的名为“jpaFlowExecutionListener”的 bean 时出错:设置时无法解析对 bean“entityManagerFactory”的引用构造函数参数;嵌套异常为 org.springframework.beans.factory.NoSuchBeanDefinitionException:未定义名为“entityManagerFactory”的 bean。

好吧,我想这个错误是因为我在 META-INF 中有 Hibernate 配置,如下所示:

  • META-INF/spring/spring-master.xml
    • META-INF/spring/spring-hibernate.xml
    • META-INF/spring/spring-datasource.xml
    • META-INF/spring/jdbc.properties

以及 WEB-INF 中的 webflow 配置: WEB-INF/spring/transportes-webflow.xml

 <?xml version="1.0" encoding="UTF-8"?>
 <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:context="http://www.springframework.org/schema/context"
    xmlns:faces="http://www.springframework.org/schema/faces"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/webflow-config
    http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
    http://www.springframework.org/schema/faces
    http://www.springframework.org/schema/faces/spring-faces-2.0.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!--Flow executor for Jpa integration and security  -->
<webflow:flow-executor id="flowExecutor">
    <webflow:flow-execution-listeners>
        <webflow:listener ref="securityFlowExecutionListener"/>
        <webflow:listener ref="jpaFlowExecutionListener"/>
    </webflow:flow-execution-listeners>
</webflow:flow-executor>

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

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

<!-- For use interface flow controller -->
<bean
        class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>

<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
    <property name="flowExecutor" ref="flowExecutor"/>
    <!--  need to tell Spring Web Flow about how to handle Ajax requests. -->
    <property name="ajaxHandler">
        <bean class="org.springframework.faces.richfaces.RichFacesAjaxHandler" />
    </property>
</bean>

<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>

<!--  LISTENER'S for SECURITY and JPA-->
<bean id="securityFlowExecutionListener"
      class="org.springframework.webflow.security.SecurityFlowExecutionListener"/>

<bean id="jpaFlowExecutionListener"
      class="org.springframework.webflow.persistence.HibernateFlowExecutionListener">
    <constructor-arg ref="entityManagerFactory"/>
    <constructor-arg ref="transactionManager"/>
</bean>

<!-- Facelets config -->
<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/flows/"/>
    <property name="suffix" value=".xhtml"/>
</bean>

这是我下载的完整提示:

https: //rapidshare.com/files/335929555/prompt-jboss.zip

谢谢

I have a error like this working with webflow 2.3.0.RELEASE and richfaces 4.0.0.Final in jboss 7.0.1.FINAL:

12:16:46,989 INFO [stdout] (MSC service thread 1-7) 2011-09-20 12:16:46,987 [MSC service thread 1-7] ERROR (FrameworkServlet.java:314) � Context initialization failed 12:16:46,989 INFO [stdout] (MSC service thread 1-7) org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowExecutor': Cannot create inner bean '(inner bean)' of type [org.springframework.webflow.config.FlowExecutionListenerLoaderFactoryBean] while setting bean property 'flowExecutionListenerLoader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1':Cannot resolve reference to bean 'jpaFlowExecutionListener' while setting bean property 'listeners'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaFlowExecutionListener' defined in ServletContext resource [/WEB-INF/spring/transportes-webflow.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' is defined.

Well I suppose that the error is because I have the Hibernate configuracion in META-INF like this:

  • META-INF/spring/spring-master.xml
    • META-INF/spring/spring-hibernate.xml
    • META-INF/spring/spring-datasource.xml
    • META-INF/spring/jdbc.properties

and the webflow configuration in WEB-INF:
WEB-INF/spring/transportes-webflow.xml

 <?xml version="1.0" encoding="UTF-8"?>
 <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:context="http://www.springframework.org/schema/context"
    xmlns:faces="http://www.springframework.org/schema/faces"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/webflow-config
    http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
    http://www.springframework.org/schema/faces
    http://www.springframework.org/schema/faces/spring-faces-2.0.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!--Flow executor for Jpa integration and security  -->
<webflow:flow-executor id="flowExecutor">
    <webflow:flow-execution-listeners>
        <webflow:listener ref="securityFlowExecutionListener"/>
        <webflow:listener ref="jpaFlowExecutionListener"/>
    </webflow:flow-execution-listeners>
</webflow:flow-executor>

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

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

<!-- For use interface flow controller -->
<bean
        class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>

<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
    <property name="flowExecutor" ref="flowExecutor"/>
    <!--  need to tell Spring Web Flow about how to handle Ajax requests. -->
    <property name="ajaxHandler">
        <bean class="org.springframework.faces.richfaces.RichFacesAjaxHandler" />
    </property>
</bean>

<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>

<!--  LISTENER'S for SECURITY and JPA-->
<bean id="securityFlowExecutionListener"
      class="org.springframework.webflow.security.SecurityFlowExecutionListener"/>

<bean id="jpaFlowExecutionListener"
      class="org.springframework.webflow.persistence.HibernateFlowExecutionListener">
    <constructor-arg ref="entityManagerFactory"/>
    <constructor-arg ref="transactionManager"/>
</bean>

<!-- Facelets config -->
<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/flows/"/>
    <property name="suffix" value=".xhtml"/>
</bean>

This is my full prompt for downloaded:

https://rapidshare.com/files/335929555/prompt-jboss.zip

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流年里的时光 2024-12-13 22:17:12
NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' is defined

意味着它无法找到 entityManagerFactory 的 bean 定义。从您的 webflow 配置中,jpaFlowExecutionListener 需要它:

<bean id="jpaFlowExecutionListener"
  class="org.springframework.webflow.persistence.HibernateFlowExecutionListener">
    <constructor-arg ref="entityManagerFactory"/>
    <constructor-arg ref="transactionManager"/>
</bean>

如果此 bean 定义在:

META-INF/spring/spring-hibernate.xml

它应该由 webflow 配置导入 (WEB-INF/spring/transportes-webflow.xml< /code>)

<import resource="classpath:META-INF/spring/spring-hibernate.xml" />

或者确保您的 Web 配置侦听器中有这两个文件:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:META-INF/spring/spring-hibernate.xml /WEB-INF/spring/transportes-webflow.xml ... </param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' is defined

means that it is unable to locate a bean definition for entityManagerFactory. From your webflow config it is needed by jpaFlowExecutionListener:

<bean id="jpaFlowExecutionListener"
  class="org.springframework.webflow.persistence.HibernateFlowExecutionListener">
    <constructor-arg ref="entityManagerFactory"/>
    <constructor-arg ref="transactionManager"/>
</bean>

In case this bean is defined in:

META-INF/spring/spring-hibernate.xml

It should either be imported by a webflow config (WEB-INF/spring/transportes-webflow.xml)

<import resource="classpath:META-INF/spring/spring-hibernate.xml" />

Or make sure you have these two files in your Web config listener:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:META-INF/spring/spring-hibernate.xml /WEB-INF/spring/transportes-webflow.xml ... </param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文