2

I recently upgrade from eclipse Juno to Luna on my Windows 7 box and am having problems with my aspectj compile. I'm getting this error:

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile (default) on project RSADirectoryUtilities: Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile failed: A required class was missing while executing org.codehaus.mojo:aspectj-maven-plugin:1.7:compile: org/aspectj/bridge/IMessageHolder
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.codehaus.mojo:aspectj-maven-plugin:1.7
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/DJC/.m2/repository/org/codehaus/mojo/aspectj-maven-plugin/1.7/aspectj-maven-plugin-1.7.jar
[ERROR] urls[1] = file:/C:/Users/DJC/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.10/plexus-utils-3.0.10.jar
[ERROR] urls[2] = file:/C:/Users/DJC/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[3] = file:/C:/Users/DJC/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
[ERROR] urls[4] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar
[ERROR] urls[5] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar
[ERROR] urls[6] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[ERROR] urls[7] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-site-renderer/1.1.2/doxia-site-renderer-1.1.2.jar
[ERROR] urls[8] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-core/1.1.2/doxia-core-1.1.2.jar
[ERROR] urls[9] = file:/C:/Users/DJC/.m2/repository/xerces/xercesImpl/2.8.1/xercesImpl-2.8.1.jar
[ERROR] urls[10] = file:/C:/Users/DJC/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
[ERROR] urls[11] = file:/C:/Users/DJC/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar
[ERROR] urls[12] = file:/C:/Users/DJC/.m2/repository/commons-codec/commons-codec/1.2/commons-codec-1.2.jar
[ERROR] urls[13] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-decoration-model/1.1.2/doxia-decoration-model-1.1.2.jar
[ERROR] urls[14] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-module-xhtml/1.1.2/doxia-module-xhtml-1.1.2.jar
[ERROR] urls[15] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/doxia/doxia-module-fml/1.1.2/doxia-module-fml-1.1.2.jar
[ERROR] urls[16] = file:/C:/Users/DJC/.m2/repository/org/codehaus/plexus/plexus-i18n/1.0-beta-7/plexus-i18n-1.0-beta-7.jar
[ERROR] urls[17] = file:/C:/Users/DJC/.m2/repository/org/codehaus/plexus/plexus-velocity/1.1.7/plexus-velocity-1.1.7.jar
[ERROR] urls[18] = file:/C:/Users/DJC/.m2/repository/org/apache/velocity/velocity/1.5/velocity-1.5.jar
[ERROR] urls[19] = file:/C:/Users/DJC/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar
[ERROR] urls[20] = file:/C:/Users/DJC/.m2/repository/commons-collections/commons-collections/3.2/commons-collections-3.2.jar
[ERROR] urls[21] = file:/C:/Users/DJC/.m2/repository/org/apache/maven/reporting/maven-reporting-impl/2.1/maven-reporting-impl-2.1.jar
[ERROR] urls[22] = file:/C:/Users/DJC/.m2/repository/commons-validator/commons-validator/1.2.0/commons-validator-1.2.0.jar
[ERROR] urls[23] = file:/C:/Users/DJC/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar
[ERROR] urls[24] = file:/C:/Users/DJC/.m2/repository/commons-digester/commons-digester/1.6/commons-digester-1.6.jar
[ERROR] urls[25] = file:/C:/Users/DJC/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar
[ERROR] urls[26] = file:/C:/Users/DJC/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
[ERROR] urls[27] = file:/C:/Users/DJC/.m2/repository/org/aspectj/aspectjtools/1.8.2/aspectjtools-1.8.2.jar
[ERROR] urls[28] = file:/C:/Program%20Files/Java/jdk1.8.0_31/jre/../lib/tools.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------: org.aspectj.bridge.IMessageHolder

My pom looks like this:

 <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.7.3</version>
  </dependency>
  <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.7.3</version>
  </dependency>

.....

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.7</version>
        <executions>
            <execution>
                <phase>process-sources</phase>
                <goals>
                    <!-- use this goal to weave all your main classes -->
                    <goal>compile</goal>
                </goals>
            </execution>
        </executions>
        <configuration>                 
            <complianceLevel>1.8</complianceLevel>
            <target>1.8</target>
            <source>1.6</source>
            <verbose>true</verbose>
        </configuration>
    </plugin>

A few interesting things to note. This works fine when I run mvn package outside of eclipse (on a linux box). I have 2 co-workers and they both are able to maven package within eclipse (they both recently upgraded too). The only difference is that they went through the upgrade path in Juno and I simply did a fresh "install" and pointed Luna and my workspace (which it upgraded). I went through plug-in by plug-in to try to find the difference between their installation and mine and that didn't fix this issue. I'm running out of ideas.

This solution seems outdated to me and doesn't work.

Running mvn dependency:tree yields

[INFO] Building xxxDirectoryUtilities 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) @ xxxDirectoryUtilities ---
[INFO] xxxDirectoryUtilities:jar:0.0.1-SNAPSHOT
[INFO] +- junit:junit:jar:4.4:test
[INFO] +- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] +- org.springframework:spring-context:jar:2.5.6:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  \- org.springframework:spring-core:jar:2.5.6:compile
[INFO] +- org.springframework:spring-tx:jar:2.5.6:compile
[INFO] +- org.springframework:spring-beans:jar:2.5.6:compile
[INFO] +- org.springframework.ldap:spring-ldap-core:jar:1.3.0.RELEASE:compile
[INFO] |  \- commons-lang:commons-lang:jar:2.1:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.7.3:compile
[INFO] +- org.aspectj:aspectjrt:jar:1.7.3:compile
[INFO] +- xxxLoggingUtilities:jar:0.0.1-SNAPSHOT:compile
[INFO] |  \- log4j:log4j:jar:1.2.17:compile
[INFO] +- xxxCryptographyUtils:jar:0.0.1-SNAPSHOT:compile
[INFO] |  \- org.jasypt:jasypt-spring2:jar:1.9.1:compile
[INFO] |     \- org.jasypt:jasypt:jar:1.9.1:compile
[INFO] \- xxx:UnifiedSpringResourceFiles:jar:0.0.1-SNAPSHOT:compile
[INFO]    \- org.springframework:spring:jar:2.5.6:compile
kriegaex
  • 63,017
  • 15
  • 111
  • 202
darrickc
  • 1,872
  • 6
  • 27
  • 38

1 Answers1

1

Your Maven configuration has a few potential problems:

  • You use AspectJ Maven Plugin 1.7 which uses compiler version 1.8.2.
  • But you have a dependency on AspectJ Runtime 1.7.3. (BTW, 1.7.4 was the latest 1.7.x AspectJ release.)
  • Your bytecode target version is 1.8, but AspectJ Runtime 1.7.x does not support Java 8.

What I usually do is:

  • Make sure the compiler and runtime versions are in sync. I even override the AspectJ Tools version in AspectJ Maven Plugin just to be 100% sure I have the latest compiler fixes.
  • Normally I also use the same source, target and compliance level versions. It does not hurt.

You can adjust this sample to your needs:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.source-target.version>1.7</java.source-target.version>
    <aspectj.version>1.8.5</aspectj.version>
    <main-class>de.scrum_master.galileo.OpenbookCleaner</main-class>
</properties>

<!-- (...) -->

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.2</version>
    <configuration>
        <source>${java.source-target.version}</source>
        <target>${java.source-target.version}</target>
        <!-- IMPORTANT -->
        <useIncrementalCompilation>false</useIncrementalCompilation>
    </configuration>
</plugin>

<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>${project.build.sourceEncoding}</encoding>
        <!--<verbose>true</verbose>-->
        <!--<warn>constructorName,packageDefaultMethod,deprecation,maskedCatchBlocks,unusedLocals,unusedArguments,unusedImport</warn>-->
    </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>

<!-- (...) -->

<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>${aspectj.version}</version>
    <scope>runtime</scope>
</dependency>

<!-- (...) -->

See if it helps.

kriegaex
  • 63,017
  • 15
  • 111
  • 202