I'm trying to get Aspectj
Compile Time Weaving
(CTW) configured in Spring
. However after adding mode="aspectj"
to the tx:annotation-driven
, the transactions all fail and no entities are stored in the database as a result.
Here is the relevant part of my configuration:
<tx:annotation-driven transaction-manager="transactionManager" mode="aspectj" />
<context:spring-configured />
<context:annotation-config />
<context:component-scan base-package='some.package' />
<aop:aspectj-autoproxy />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id='entityManagerFactory' class='org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean'><property name="persistenceUnitName" value="myPU" />
<property name="dataSource" ref="dataSource" />
</bean>
I also have a aop.xml in /META-INF (not sure the file is needed though)
<!DOCTYPE aspectj PUBLIC
"-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver>
<!-- only weave classes in our application-specific packages -->
<include within="some.package.*" />
</weaver>
<aspects>
<aspect
name="org.springframework.transaction.aspectj.AnnotationTransactionAspect" />
</aspects>
</aspectj>
Some remarks:
- I am stuck to CTW (so no LTW) because of the environment I'm working with.
- I use
@PersistenceContext
to get theEntityManager
- Without mode="aspectj" in tx:annotation-driven the transactions run fine
- I'm not using
Spring MVC
- I'm using GWT 2.5
edit:
My project has a Maven
nature, and I had to add this plugin too. But I run the application using Eclipse
and the Google Plugin
. I run the project as A Web Application (google plugin)
. I'm not sure if this code in Maven
is properly initialised...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<complianceLevel>1.6</complianceLevel>
<encoding>UTF-8</encoding>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>