Reputation: 23443
My aspectj classes are not getting compiled despite that they are annotated with @Aspect and are residing in .aj extension files.
This project is a Maven JBoss AS 7 EAR Archetype.
[INFO] --- aspectj-maven-plugin:1.4:compile (default-cli) @ hms ---
[WARNING] Not executing aspectJ compiler as the project is not a Java classpath-capable package
[INFO] --- aspectj-maven-plugin:1.4:compile (default-cli) @ hms-ejb ---
[WARNING] bad version number found in C:\Users\Oh Chin Boon\.m2\repository\org\aspectj\aspectjrt\1.5.4\aspectjrt-1.5.4.jar expected 1.6.11 found 1.5.4
[WARNING] advice defined in sg.java.hms.aspect.AbstractLoggingAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in sg.java.hms.aspect.DefaultLoggingAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in sg.java.hms.aspect.AbstractLoggingAspect has not been applied [Xlint:adviceDidNotMatch]
EDIT: pom.xml snippet
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>compile</goal> <!-- use this goal to weave all your main classes -->
</goals>
</execution>
</executions>
</plugin>
Upvotes: 4
Views: 7284
Reputation: 1337
I just crossed by this issue, this was my scenario: Here my mojo plugin config:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<complianceLevel>1.7</complianceLevel>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
And my Aspectj dependency:
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.5</version>
</dependency>
When compiling (maven install) I notice this messages:
[INFO] --- aspectj-maven-plugin:1.7:compile (default) @ com.wu.bishopframework ---
Downloading: …aspectj/aspectjtools/1.8.2/aspectjtools-1.8.2.pom
Downloaded: …aspectj/aspectjtools/1.8.2/aspectjtools-1.8.2.pom (1021 B at 2.3 KB/sec)
Downloading: …aspectj/aspectjtools/1.8.2/aspectjtools-1.8.2.jar
Downloaded: …aspectj/aspectjtools/1.8.2/aspectjtools-1.8.2.jar (10897 KB at 141.7 KB/sec)
[INFO] No modifications found skipping aspectJ compile
Then I got this message:
[WARNING] bad version number found in C:\Users\mavargas\.m2\repository\org\aspectj\aspectjrt\1.8.5\aspectjrt-1.8.5.jar expected 1.8.2 found 1.8.5
The solution was simple, just add the dependency of aspectjtools inside the plugin as shown here:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.8.5</version>
</dependency>
</dependencies>
<configuration>
<source>1.7</source>
<target>1.7</target>
<complianceLevel>1.7</complianceLevel>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
This fixed the issue.
Hope it helps somebody crossing by the same situation...
Upvotes: 2
Reputation: 28757
Somehow you are referencing aspectj 1.5.4, but your source and target levels are 1.6. AspectJ 1.5.x only targets Java 1.5. You need to explicitly specify AspectJ 1.6. Something like this should work in your dependencies section:
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.12</version>
</dependency>
Upvotes: 5