论坛首页 Java版 Spring

Sring2.0采用TransactionInterceptor事务配置出现的奇怪错误

浏览 993 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
最后更新时间:2007-08-24 关键字: spring java hibernate
这是事务配置的部分
 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

	<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">   
	  <property name="transactionManager" ref="transactionManager"></property>   
	  <property name="transactionAttributes">   
	   <props>   
	    <prop key="save*">PROPAGATION_REQUIRED</prop>   
	    <prop key="add*">PROPAGATION_REQUIRED</prop>   
	    <prop key="set*">PROPAGATION_REQUIRED</prop>   
	    <prop key="update*">PROPAGATION_REQUIRED</prop>   
	    <prop key="delete*">PROPAGATION_REQUIRED</prop>   
	    <prop key="remove">PROPAGATION_REQUIRED</prop>           
	    <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>   
	    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>   
	   </props>   
	  </property>   
	 </bean>   
	 <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        <property name="beanNames">
             <list>
               <value>*Manager</value>
            </list>
        </property>
        <property name="interceptorNames">
            <list>
                <value>transactionInterceptor</value>
            </list>
        </property>
    </bean>
	 
	   
	 <bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">   
	  <property name="transactionInterceptor" ref="transactionInterceptor">   
	  </property>   
	 </bean>   


启动Tomcat报的错误:
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'transactionManager': Bean with name 'transactionManager' has been injected into other beans [transactionInterceptor] in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of auto-proxy creation). This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:432)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
	at org.apache.catalina.core.StandardService.start(StandardService.java:516)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
   
最后更新时间:2008-06-26
兄弟
<property name="beanNames">  
            <list>  
              <value>*Manager</value>  
           </list>  
       </property>
这的问题!
transactionManager后边也是Manager。这样会把transactionInterceptor注入到transactionManager。造成这个错误你吧Manager改成其它的就没事了
   
0 请登录后投票
论坛首页 Java版 Spring

跳转论坛:
JavaEye推荐