一个struts2+spring2.5.5+hibernate3.3.1的小项目本来一切正常,今天加上spring的声明事务之后,报错,网上说Struts2不支持用代理来拦截actionhttps://issues.apache.org/struts/browse/WW-2547Agreed, Struts 2 doesn't support proxies for interceptors and actions, and the workaround seems to fix your issue. However, if you really feel Struts 2 should support proxies, please open a new feature ticket. 
[ Show » ] Don Brown - 14/Jul/08 06:14 AM Agreed, Struts 2 doesn't support proxies for interceptors and actions, and the workaround seems to fix your issue. However, if you really feel Struts 2 should support proxies, please open a new feature ticket. 
真的假的?有人知道吗?大家帮个忙,怎么解决这个问题啊,我想在 struts2+spring2.5.5+hibernate3.3.1 上用声明事务-------------------------------
以下为加上声明事务后报的错
----------------------------------Caught OgnlException while setting property 'excludeMethods' on type '$Proxy12'.
ognl.NoSuchPropertyException: $Proxy12.excludeMethods----------------applicationContext.xml中的声明事务管理--------------------<!--   定义事务管理器,使用适用于Hibernte的事务管理器-->
<bean id="transactionManager"
         class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <!--   HibernateTransactionManager   bean需要依赖注入一个SessionFactory bean的引用-->
            <property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
     <!--   配置事务拦截器-->
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
        <!--   事务拦截器bean需要依赖注入一个事务管理器 -->
        <property name="transactionManager" ref="transactionManager"/>
        <property name="transactionAttributes">
            <!--   下面定义事务传播属性-->
            <props>
                <prop key="insert*">PROPAGATION_REQUIRED</prop>
                <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
</bean>
     <!--   定义事务Advisor-->
<bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
        <!--   定义advisor时,必须传入Interceptor-->
            <property name="transactionInterceptor" ref="transactionInterceptor"/>
     </bean>
     <!-- DefaultAdvisorAutoProxyCreator搜索容器中的 advisor,并为每个bean创建代理 -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
<!--定义DAO Bean ,由于BeanNameAutoProxyCreator自动生成事务代理-->
     <bean id="iUserDao" class="com.tinyblog.dao.impl.UserDaoImpl">
         <property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

解决方案 »

  1.   

    你是不是把事务配置到action那一层了,这样的话就变成嵌套代理了,本身struts2的action是用代理wrap了一下,spring 的事务也要wrap一下,这就变成了2层的代理,以我所知是不支持的。你把事务配置到service层吧
      

  2.   

    我只是把dao的实现代理了一下啊,,郁闷
      

  3.   

    stuts2还没实践过,听说可用性不是特别强。