Hi,
I am using Struts2+Spring+JPA/Hibernate. When I use the @Transactional to
mark an execute() method in a Struts2 Action, the action stops working
properly (i.e. the attributes in the action are not automatically setted).
It does not work with Spring AOP transactions as well.
In my struts.config I setted the following constant:
----
<constant name="struts.objectFactory" value="spring" />
----
In my applicationContext.xml I set the pointcut to the actions. I have the
following:
----
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="execute" propagation="REQUIRED"
rollback-for="package.RepositorioException" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="ActionsComTransacao"
expression="execution(* package.actions.*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="ActionsComTransacao" />
</aop:config>
----
And in my web.config I have open-session-in-view, struts2 filters and the
spring listener:
----
<filter>
<filter-name>open-session-in-view</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
<init-param>
<param-name>entityManagerFactoryBeanName</param-name>
<param-value>entityManagerFactory</param-value>
</init-param>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>open-session-in-view</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<description>Spring Listener</description>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
----
The funny thing is that if I use the transaction aspect in any other package
(i.e. my repositories) everything works fine. It just crashes when I use it
in the struts action.
Any idea?
Thanks in advance,
Mauricio