[ https://jira.codehaus.org/browse/MNG-5787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=365719#comment-365719 ]
Christian Schlichtherle commented on MNG-5787: ---------------------------------------------- @Dan Tran: Thanks for the hint. I have inspected the patch, but this isn't really a fix. At best, it's a workaround which I suspect to break on any other use of the SLF4J API in the plugin. I have investigated the case and prepared a very simple test plugin (only 3 files) which runs fine with Maven 3.2.5, but breaks with Maven 3.3.1 - see attached ZIP file. The archive contains the following files: * {{pom.xml}}: Copied from http://maven.apache.org/guides/plugin/guide-java-plugin-development.html and added a dependency on the SLF4J API version 1.7.5. This is the same version as the one that ships with Maven 3.3.1. * {{src/main/java/sample/plugin.LoggerAdapter.java}}: Extends {{org.slf4j.helpers.MarkerIgnoringBase}} and adapts it to {{org.apache.maven.plugin.logging.Log}}. I need this class in my TrueLicense Maven Plugin. * {{src/main/java/sample/plugin/GreetingMojo.java}}: Copied from the same page and edited it to use the {{LoggerAdapter}} class. After building the plugin, I can run its MOJO using Maven 3.2.5 just fine: {code} $ M2_HOME=/usr/local/Cellar/maven/3.2.5/libexec mvn sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi -e [INFO] Error stacktraces are turned on. [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- hello-maven-plugin:1.0-SNAPSHOT:sayhi (default-cli) @ standalone-pom --- [INFO] Hello, world. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.134 s [INFO] Finished at: 2015-03-26T15:27:04+01:00 [INFO] Final Memory: 8M/309M [INFO] ------------------------------------------------------------------------ {code} Now using Maven 3.3.1, I get the following error message: {code} $ M2_HOME=/usr/local/Cellar/maven/3.3.1/libexec mvn sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi -e [INFO] Error stacktraces are turned on. [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- hello-maven-plugin:1.0-SNAPSHOT:sayhi (default-cli) @ standalone-pom --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.126 s [INFO] Finished at: 2015-03-26T15:27:48+01:00 [INFO] Final Memory: 8M/309M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi (default-cli) on project standalone-pom: Execution default-cli of goal sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi failed: A required class was missing while executing sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi: org/slf4j/helpers/MarkerIgnoringBase [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>sample.plugin:hello-maven-plugin:1.0-SNAPSHOT [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/Users/christian/.m2/repository/sample/plugin/hello-maven-plugin/1.0-SNAPSHOT/hello-maven-plugin-1.0-SNAPSHOT.jar [ERROR] urls[1] = file:/Users/christian/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR] -----------------------------------------------------: org.slf4j.helpers.MarkerIgnoringBase [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi (default-cli) on project standalone-pom: Execution default-cli of goal sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi failed: A required class was missing while executing sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi: org/slf4j/helpers/MarkerIgnoringBase ----------------------------------------------------- realm = plugin>sample.plugin:hello-maven-plugin:1.0-SNAPSHOT strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy urls[0] = file:/Users/christian/.m2/repository/sample/plugin/hello-maven-plugin/1.0-SNAPSHOT/hello-maven-plugin-1.0-SNAPSHOT.jar urls[1] = file:/Users/christian/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar Number of foreign imports: 1 import: Entry[import from realm ClassRealm[maven.api, parent: null]] ----------------------------------------------------- at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi failed: A required class was missing while executing sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi: org/slf4j/helpers/MarkerIgnoringBase ----------------------------------------------------- realm = plugin>sample.plugin:hello-maven-plugin:1.0-SNAPSHOT strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy urls[0] = file:/Users/christian/.m2/repository/sample/plugin/hello-maven-plugin/1.0-SNAPSHOT/hello-maven-plugin-1.0-SNAPSHOT.jar urls[1] = file:/Users/christian/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar Number of foreign imports: 1 import: Entry[import from realm ClassRealm[maven.api, parent: null]] ----------------------------------------------------- at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:168) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 20 more Caused by: org.apache.maven.plugin.PluginContainerException: A required class was missing while executing sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi: org/slf4j/helpers/MarkerIgnoringBase ----------------------------------------------------- realm = plugin>sample.plugin:hello-maven-plugin:1.0-SNAPSHOT strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy urls[0] = file:/Users/christian/.m2/repository/sample/plugin/hello-maven-plugin/1.0-SNAPSHOT/hello-maven-plugin-1.0-SNAPSHOT.jar urls[1] = file:/Users/christian/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar Number of foreign imports: 1 import: Entry[import from realm ClassRealm[maven.api, parent: null]] ----------------------------------------------------- at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:166) ... 21 more Caused by: java.lang.NoClassDefFoundError: org/slf4j/helpers/MarkerIgnoringBase at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401) at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42) at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239) at sample.plugin.GreetingMojo.execute(GreetingMojo.java:10) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) ... 21 more Caused by: java.lang.ClassNotFoundException: org.slf4j.helpers.MarkerIgnoringBase at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239) ... 37 more [ERROR] [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException {code} This is becoming a critical issue for me. Any help is greatly appreciated. > Regression: The class path is missing a compile time dependency of a plugin > --------------------------------------------------------------------------- > > Key: MNG-5787 > URL: https://jira.codehaus.org/browse/MNG-5787 > Project: Maven > Issue Type: Bug > Components: Class Loading > Affects Versions: 3.3.1 > Environment: OS X 10.10.2, JDK 1.7.0_76 and JDK 1.8.0_40. > Reporter: Christian Schlichtherle > Priority: Blocker > Attachments: hello-maven-plugin.zip > > > There is a regression when setting up the class path for a plugin in Maven > 3.3.1. The following commands run fine when using Maven 3.2.5 or older: > {code} > $ mvn --version > Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; > 2014-12-14T18:29:23+01:00) > Maven home: /usr/local/Cellar/maven/3.2.5/libexec > Java version: 1.8.0_40, vendor: Oracle Corporation > Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre > Default locale: de_DE, platform encoding: UTF-8 > OS name: "mac os x", version: "10.10.2", arch: "x86_64", family: "mac" > $ mvn archetype:generate \ > -DarchetypeGroupId=net.java.truelicense \ > -DarchetypeArtifactId=truelicense-maven-archetype \ > -DarchetypeVersion=2.3.4 \ > -DgroupId=com.company.product \ > -DartifactId=product \ > -Dversion=0.1-SNAPSHOT \ > -Dpackage=com.company.product \ > -Dsubject="Product 1" > [...] > $ cd project > $ mvn clean install > [...] > {code} > Note that I have shortened the output using bracketed ellipsis {{\[...\]}}. > However, when running the same commands using Maven 3.3.1, I get the > following output: > {code} > $ mvn --version > Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; > 2015-03-13T21:10:27+01:00) > Maven home: /Users/christian/Downloads/apache-maven-3.3.1 > Java version: 1.8.0_40, vendor: Oracle Corporation > Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre > Default locale: de_DE, platform encoding: UTF-8 > OS name: "mac os x", version: "10.10.2", arch: "x86_64", family: "mac" > $ mvn archetype:generate \ > -DarchetypeGroupId=net.java.truelicense \ > -DarchetypeArtifactId=truelicense-maven-archetype \ > -DarchetypeVersion=2.3.4 \ > -DgroupId=com.company.product \ > -DartifactId=product \ > -Dversion=0.1-SNAPSHOT \ > -Dpackage=com.company.product \ > -Dsubject="Product 1" > [...] > $ cd project > $ mvn clean install > [INFO] Scanning for projects... > [INFO] > ------------------------------------------------------------------------ > [INFO] Reactor Build Order: > [INFO] > [INFO] product > [INFO] keygen > [INFO] keymgr > [INFO] keysrv > [INFO] > > [INFO] > ------------------------------------------------------------------------ > [INFO] Building product 0.1-SNAPSHOT > [INFO] > ------------------------------------------------------------------------ > [INFO] > [INFO] --- maven-clean-plugin:2.6:clean (default-clean) @ product --- > [INFO] > [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-maven) @ product --- > [INFO] > [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ product --- > [INFO] Installing /Users/christian/sandbox/truelicense/product/pom.xml to > /Users/christian/.m2/repository/com/company/product/product/0.1-SNAPSHOT/product-0.1-SNAPSHOT.pom > [INFO] > > [INFO] > ------------------------------------------------------------------------ > [INFO] Building keygen 0.1-SNAPSHOT > [INFO] > ------------------------------------------------------------------------ > [INFO] > [INFO] --- maven-clean-plugin:2.6:clean (default-clean) @ keygen --- > [INFO] Deleting /Users/christian/sandbox/truelicense/product/keygen/target > [INFO] > [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-maven) @ keygen --- > [INFO] > [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ keygen > --- > [INFO] Using 'US-ASCII' encoding to copy filtered resources. > [INFO] Copying 1 resource > [INFO] Copying 1 resource > [INFO] > [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ keygen --- > [INFO] Changes detected - recompiling the module! > [INFO] Compiling 2 source files to > /Users/christian/sandbox/truelicense/product/keygen/target/classes > [INFO] > [INFO] --- truelicense-maven-plugin:2.3.4:obfuscate (default) @ keygen --- > [INFO] Obfuscating annotated constant string values in > /Users/christian/sandbox/truelicense/product/keygen/target/classes. > [INFO] > ------------------------------------------------------------------------ > [INFO] Reactor Summary: > [INFO] > [INFO] product ............................................ SUCCESS [ 0.411 > s] > [INFO] keygen ............................................. FAILURE [ 1.022 > s] > [INFO] keymgr ............................................. SKIPPED > [INFO] keysrv ............................................. SKIPPED > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD FAILURE > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 1.646 s > [INFO] Finished at: 2015-03-18T19:31:46+01:00 > [INFO] Final Memory: 15M/245M > [INFO] > ------------------------------------------------------------------------ > [ERROR] Failed to execute goal > net.java.truelicense:truelicense-maven-plugin:2.3.4:obfuscate (default) on > project keygen: Execution default of goal > net.java.truelicense:truelicense-maven-plugin:2.3.4:obfuscate failed: A > required class was missing while executing > net.java.truelicense:truelicense-maven-plugin:2.3.4:obfuscate: > org/slf4j/helpers/MarkerIgnoringBase > [ERROR] ----------------------------------------------------- > [ERROR] realm = plugin>net.java.truelicense:truelicense-maven-plugin:2.3.4 > [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy > [ERROR] urls[0] = > file:/Users/christian/.m2/repository/net/java/truelicense/truelicense-maven-plugin/2.3.4/truelicense-maven-plugin-2.3.4.jar > [ERROR] urls[1] = > file:/Users/christian/.m2/repository/net/java/truelicense/truelicense-obfuscate/2.3.4/truelicense-obfuscate-2.3.4.jar > [ERROR] urls[2] = > file:/Users/christian/.m2/repository/de/schlichtherle/truezip/truezip-driver-zip/7.7.6/truezip-driver-zip-7.7.6.jar > [ERROR] urls[3] = > file:/Users/christian/.m2/repository/de/schlichtherle/truezip/truezip-swing/7.7.6/truezip-swing-7.7.6.jar > [ERROR] urls[4] = > file:/Users/christian/.m2/repository/org/apache/commons/commons-compress/1.9/commons-compress-1.9.jar > [ERROR] urls[5] = > file:/Users/christian/.m2/repository/de/schlichtherle/truezip/truezip-kernel/7.7.6/truezip-kernel-7.7.6.jar > [ERROR] urls[6] = > file:/Users/christian/.m2/repository/de/schlichtherle/truezip/truezip-file/7.7.6/truezip-file-7.7.6.jar > [ERROR] urls[7] = > file:/Users/christian/.m2/repository/de/schlichtherle/truezip/truezip-driver-file/7.7.6/truezip-driver-file-7.7.6.jar > [ERROR] urls[8] = > file:/Users/christian/.m2/repository/org/ow2/asm/asm-tree/5.0.3/asm-tree-5.0.3.jar > [ERROR] urls[9] = > file:/Users/christian/.m2/repository/org/ow2/asm/asm/5.0.3/asm-5.0.3.jar > [ERROR] urls[10] = > file:/Users/christian/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar > [ERROR] Number of foreign imports: 1 > [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] > [ERROR] > [ERROR] -----------------------------------------------------: > org.slf4j.helpers.MarkerIgnoringBase > [ERROR] -> [Help 1] > [ERROR] > [ERROR] To see the full stack trace of the errors, re-run Maven with the -e > switch. > [ERROR] Re-run Maven using the -X switch to enable full debug logging. > [ERROR] > [ERROR] For more information about the errors and possible solutions, please > read the following articles: > [ERROR] [Help 1] > http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException > [ERROR] > [ERROR] After correcting the problems, you can resume the build with the > command > [ERROR] mvn <goals> -rf :keygen > {code} > {{org.slf4j.helpers.MarkerIgnoringBase}} is a class in the SLF4J API. Version > 1.7.7 is a compile dependency of the TrueLicense Maven Plugin, as can be seen > at > https://repo1.maven.org/maven2/net/java/truelicense/truelicense-maven-plugin/2.3.4/truelicense-maven-plugin-2.3.4.pom > , however it is apparently missing on the class path when building the > project with Maven 3.3.1. > Using a 1.7 JDK makes no difference, too. -- This message was sent by Atlassian JIRA (v6.1.6#6162)