Could not find dependencies for aspectj-maven-plugin

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?

Answers


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.


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


Need Your Help

Finding information within a SQL string

sql-server tsql

I have a query (sql-server) in which I am trying to pull information out of a string.