I try to use aspectj maven plugin for compile project with aspectj compiler and then I try to package classes into \"war\" file. Unfortunately, it doesn\'t work with following c
make sure the modules has source code,like *.java etc. when i compile CAS on version 4.0.6 it happens this error, I found the cas-server-uber-webapp doesn't has any source code in src folder. just remove the module from parent pom.xml.
Update: While the things I said about AspectJ Maven configuration in this answer are all correct, the root cause of the concrete problem at hand - bad Maven dependency management - is described in my other answer. It would be better if that one was the accepted answer and not this one.
<compilationLevel>
tag (typo?) - to <complianceLevel>
.<execution>
section, the one at plugin level is enough. <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.source-target.version>1.8</java.source-target.version>
<aspectj.version>1.8.4</aspectj.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>${java.source-target.version}</source>
<target>${java.source-target.version}</target>
<Xlint>ignore</Xlint>
<complianceLevel>${java.source-target.version}</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<!-- IMPORTANT -->
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
</dependencies>
It seems like a known issue http://jira.codehaus.org/browse/MASPECTJ-125
You can fix it by adding the following to your pom file.
<complianceLevel>1.6</complianceLevel>
Having looked at your Maven project https://github.com/dmitrievanthony/test-aspectj I found out that
Here is a screenshot (full size here) from IntelliJ IDEA's "find class":
As you can see, class LockModeType
is found in 3 (three!) dependencies, one of which contains a version of the class which does not contain the expected enum values. Your code compiles if you remove this dependency.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>ejb3-persistence</artifactId>
<version>1.0.2.GA</version>
</dependency>
Maybe you should clean up your dependencies. You can use the Maven Dependency Plugin with goals like dependency:analyze
and dependency:tree
for that purpose.
It will be work after change plugin configuration to following:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<complianceLevel>1.7</complianceLevel>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<complianceLevel>1.7</complianceLevel>
<source>1.7</source>
<target>1.7</target>
</configuration>
</execution>
</executions>
</plugin>
But after this I get a lot of different compilation errors:
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.6:compile (default) on project tvbs-portlet: Compiler errors:
[ERROR] error at Entitle.class, entitleId, LockModeType.PESSIMISTIC_WRITE);
[ERROR]
[ERROR] /Users/<...>/ejb/BillingEJB.java:43:0::0 PESSIMISTIC_WRITE cannot be resolved or is not a field
[ERROR] error at .createQuery("select e from Entitle e " +
[ERROR]
[ERROR] /Users/<...>/ejb/EntitleEJB.java:62:0::0 The method createQuery(String) in the type EntityManager is not applicable for the arguments (String, Class<Entitle>)
[ERROR] error at return entityManager.createQuery(
[ERROR] ^^
Can cause is incorrect aspectj plugin parameters?