4

I have a problem with CTW aspects using aspectj-maven-plugin. I get the following error (execution entry is being highlighted):

Multiple annotations found at this line:
    - Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.5:compile failed: Plugin 
     org.codehaus.mojo:aspectj-maven-plugin:1.5 or one of its dependencies could not be resolved: Could not find artifact 
     com.sun:tools:jar:1.7.0_21 at specified path C:\Program Files\Java\jre7/../lib/tools.jar (org.codehaus.mojo:aspectj-maven-
     plugin:1.5:compile:default:compile)
    - Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.5:test-compile failed: Plugin 
     org.codehaus.mojo:aspectj-maven-plugin:1.5 or one of its dependencies could not be resolved: Could not find artifact 
     com.sun:tools:jar:1.7.0_21 at specified path C:\Program Files\Java\jre7/../lib/tools.jar (org.codehaus.mojo:aspectj-maven-
     plugin:1.5:test-compile:default:test-compile)

On the configuration:

<build>
        <plugins>
            <!-- http://mojo.codehaus.org/aspectj-maven-plugin/usage.html -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.5</version>
                <configuration>
                    <showWeaveInfo>true</showWeaveInfo>
                    <outxml>true</outxml>
                    <source>1.7</source>
                    <target>1.7</target>
                    <sources>
                        <source>
                            <basedir>src/main/java</basedir>
                            <includes>
                                <include>**/*Aspect.java</include>
                            </includes>
                        </source>
                    </sources>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

What am I doing wrong? It looks like as if this plugin was unable to find jdk? But why?

kboom
  • 2,279
  • 3
  • 28
  • 43

3 Answers3

0

Is your JAVA_HOME set properly? Please check that. It worked perfectly for me. So I think you should add below mentioned plugin and try:

<plugin>      
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
    </configuration>
   </plugin>

Run mvn compile after that.

Amit Shakya
  • 1,396
  • 12
  • 27
0

Please check the JAVA_HOME env variable. This happened to me when JAVA_HOME is pointed to JRE folder rather than jdk folder.

Adiesha
  • 133
  • 2
  • 9
  • Welcome to Stack Overflow, please elaborate a bit. Can you provide a code example, maybe? – JJJ Mar 18 '19 at 06:41
0

I had this problem running with java 11, seems like it is only compatible with java 8.

Looking into the project, aspectj-maven-plugin it looks like the update was committed but never actually merged.

James Wagstaff
  • 150
  • 1
  • 7