Hi,
I have a Spring 3.0.6 project which uses some AspectJ annotated Spring aspects for Spring AOP. Everything works fine. My JUnit tests compile and run as expected, and all my aspects are called according to their pointcuts.
However, I have recently run into the need for some AspectJ aspects. So I created my .aj aspects and pointcuts and enabled AspectJ nature on my project.
Now, suddenly, I'm running into trouble. My Junit tests instantiate my Spring @Aspects twice; once properly (all beans are properly injected) and once incorrectly (nothing is injected). When subsequent calls are made to the advice, it fails as the improper bean/aspect/advice is called (the bean with nothing injected) and all my injected values are null.
If I removed the AspectJ nature, then the project runs properly, but my AJ aspect is not woven.
I am using Maven and have the following aspectj related configuration in my pom.xml:
Is there some special way to configure this?Code:... ... <!-- Aspect Oriented Programming (AOP) Framework (depends on spring-core, spring-beans) Define this if you use Spring AOP APIs (org.springframework.aop.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Support for AspectJ Annotations --> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${org.aspectj}</version> </dependency> <!-- AspectJ weaving --> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>${org.aspectj}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjtools</artifactId> <version>${org.aspectj}</version> </dependency> ... ... ... <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>aspectj-maven-plugin</artifactId> <version>1.4</version> <configuration> <source>1.6</source> <target>1.6</target> <weaveDependencies> <weaveDependency> <groupId>commons-pool</groupId> <artifactId>commons-pool</artifactId> </weaveDependency> </weaveDependencies> </configuration> <executions> <execution> <goals> <goal>compile</goal> <goal>test-compile</goal> </goals> </execution> </executions> </plugin>
Thanks!
Eric


Reply With Quote
