Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-70773

maven-plugin and swarm plugin icw maven is not working due to a log4j dependency error

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • Swarm Version 3.39 (latest)
      Maven Integration plugin Version 3.21 (latest) (with Maven 3.9.0 (latest))
      Jenkins Jenkins 2.387.1 (latest)

      We are using the swarm-plugin to run our slave machines. On these machines we run maven test jobs. When we start the maven test an error is shown that there is a conflict on slf4j.logger

      When I downgrade the swarm plugin to version 3.34 it is working. 

      A similar problem happened in the past: JENKINS-42098

          [JENKINS-70773] maven-plugin and swarm plugin icw maven is not working due to a log4j dependency error

          Hey,

          I found the same behavior in version `3.20`. The stack trace is pretty similar:

           

          ```
          [WARNING] LinkageError while performing UserRequest:hudson.maven.Maven3Builder@46a3de7a
          java.lang.LinkageError: loader constraint violation: loader org.codehaus.plexus.classworlds.realm.ClassRealm @445b84c0 wants to load interface org.slf4j.Logger. A different interface with the same name was previously loaded by org.codehaus.plexus.classworlds.realm.ClassRealm @6e3c1e69. (org.slf4j.Logger is in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @6e3c1e69, parent loader 'xxxxxxxxxx')
           at java.base/java.lang.ClassLoader.defineClass1(Native Method)
           at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
           at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) 
           at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:555)
           at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458) 
           at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
           at java.base/java.security.AccessController.doPrivileged(Native Method)
           at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
           at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:425)
           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 org.apache.maven.cli.event.ExecutionEventLogger.<init>(ExecutionEventLogger.java:65)
           at hudson.maven.util.ExecutionEventLogger.<init>(ExecutionEventLogger.java:65)
           at hudson.maven.Maven3Builder$MavenExecutionListener.<init>(Maven3Builder.java:375)
           at hudson.maven.Maven3Builder$JenkinsEventSpy.<init>(Maven3Builder.java:199)
           at hudson.maven.Maven3Builder.call(Maven3Builder.java:119)
           at hudson.maven.Maven3Builder.call(Maven3Builder.java:70)
           at hudson.remoting.UserRequest.perform(UserRequest.java:211)
           at hudson.remoting.UserRequest.perform(UserRequest.java:54)
           at hudson.remoting.Request$2.run(Request.java:377)
           at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
           at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
           at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
           at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
           at java.base/java.lang.Thread.run(Thread.java:829)
          ERROR: Failed to parse POMs
          java.io.IOException: Remote call on Channel to Maven [$JAVA_PATH/java, -cp, /$AGENT_PATH/maven35-agent.jar:/$MAVEN_PATH/apache-maven-3.x/boot/plexus-classworlds-2.6.0.jar:/$AGENT_PATH/tools/maven/apache-maven-3.x/conf/logging, jenkins.maven3.agent.Maven35Main, /$AGENT_PATH/tools/maven/apache-maven-3.x, /$AGENT_PATH/swarm-client/swarm-client.jar, /$AGENT_PATH/maven35-interceptor.jar, /$AGENT_PATH/maven3-interceptor-commons.jar, 38414] failed
           at hudson.remoting.Channel.call(Channel.java:1004)
           at hudson.maven.ProcessCache$MavenProcess.call(ProcessCache.java:161)
           at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:877)
           at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:526)
           at hudson.model.Run.execute(Run.java:1900)
           at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
           at hudson.model.ResourceController.execute(ResourceController.java:101)
           at hudson.model.Executor.run(Executor.java:442)
          Caused by: java.lang.LinkageError: loader constraint violation: loader org.codehaus.plexus.classworlds.realm.ClassRealm @445b84c0 wants to load interface org.slf4j.Logger. A different interface with the same name was previously loaded by org.codehaus.plexus.classworlds.realm.ClassRealm @6e3c1e69. (org.slf4j.Logger is in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @6e3c1e69, parent loader 'xxxxxxxxx')
           at java.base/java.lang.ClassLoader.defineClass1(Native Method)
           at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
           at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
           at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:555)
           at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
           at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
           at java.base/java.security.AccessController.doPrivileged(Native Method)
           at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
           at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:425)
           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 org.apache.maven.cli.event.ExecutionEventLogger.<init>(ExecutionEventLogger.java:65)
           at hudson.maven.util.ExecutionEventLogger.<init>(ExecutionEventLogger.java:65)
           at hudson.maven.Maven3Builder$MavenExecutionListener.<init>(Maven3Builder.java:375)
           at hudson.maven.Maven3Builder$JenkinsEventSpy.<init>(Maven3Builder.java:199)
           at hudson.maven.Maven3Builder.call(Maven3Builder.java:119)
           at hudson.maven.Maven3Builder.call(Maven3Builder.java:70)
           at hudson.remoting.UserRequest.perform(UserRequest.java:211)
           at hudson.remoting.UserRequest.perform(UserRequest.java:54)
           at hudson.remoting.Request$2.run(Request.java:377)
           at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
           at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
           at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
           at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
           at java.base/java.lang.Thread.run(Thread.java:829)
          Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to Channel to Maven [/$JAVA_PATH/java, -cp, /data/jenkins/maven35-agent.jar:/$AGENT_PATH/tools/maven/apache-maven-3.x/boot/plexus-classworlds-2.6.0.jar:/$AGENT_PATH/tools/maven/apache-maven-3.x/conf/logging, jenkins.maven3.agent.Maven35Main, /$AGENT_PATH/tools/maven/apache-maven-3.x, /$AGENT_PATH/swarm-client/swarm-client.jar, /$AGENT_PATH/maven35-interceptor.jar, /$AGENT_PATH/maven3-interceptor-commons.jar, 38414]
           at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1784)
           at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
           at hudson.remoting.Channel.call(Channel.java:1000)
           at hudson.maven.ProcessCache$MavenProcess.call(ProcessCache.java:161)
           at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:877)
           at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:526)
           at hudson.model.Run.execute(Run.java:1900)
           at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
           at hudson.model.ResourceController.execute(ResourceController.java:101)
           at hudson.model.Executor.run(Executor.java:442)
          ```

           

          Apparently, it is a regression issue that was solved in https://issues.jenkins.io/browse/JENKINS-42098 but was re-introduced in https://issues.jenkins.io/browse/JENKINS-50970.

          Ignacio Roncero Bazarra added a comment - Hey, I found the same behavior in version `3.20`. The stack trace is pretty similar:   ``` [WARNING] LinkageError while performing UserRequest:hudson.maven.Maven3Builder@46a3de7a java.lang.LinkageError: loader constraint violation: loader org.codehaus.plexus.classworlds.realm.ClassRealm @445b84c0 wants to load interface org.slf4j.Logger. A different interface with the same name was previously loaded by org.codehaus.plexus.classworlds.realm.ClassRealm @6e3c1e69. (org.slf4j.Logger is in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @6e3c1e69, parent loader 'xxxxxxxxxx')  at java.base/java.lang.ClassLoader.defineClass1(Native Method)  at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)  at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)   at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:555)  at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)   at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)  at java.base/java.security.AccessController.doPrivileged(Native Method)  at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)  at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:425)  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 org.apache.maven.cli.event.ExecutionEventLogger.<init>(ExecutionEventLogger.java:65)  at hudson.maven.util.ExecutionEventLogger.<init>(ExecutionEventLogger.java:65)  at hudson.maven.Maven3Builder$MavenExecutionListener.<init>(Maven3Builder.java:375)  at hudson.maven.Maven3Builder$JenkinsEventSpy.<init>(Maven3Builder.java:199)  at hudson.maven.Maven3Builder.call(Maven3Builder.java:119)  at hudson.maven.Maven3Builder.call(Maven3Builder.java:70)  at hudson.remoting.UserRequest.perform(UserRequest.java:211)  at hudson.remoting.UserRequest.perform(UserRequest.java:54)  at hudson.remoting.Request$2.run(Request.java:377)  at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)  at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)  at java.base/java.lang.Thread.run(Thread.java:829) ERROR: Failed to parse POMs java.io.IOException: Remote call on Channel to Maven [$JAVA_PATH/java, -cp, /$AGENT_PATH/maven35-agent.jar:/$MAVEN_PATH/apache-maven-3.x/boot/plexus-classworlds-2.6.0.jar:/$AGENT_PATH/tools/maven/apache-maven-3.x/conf/logging, jenkins.maven3.agent.Maven35Main, /$AGENT_PATH/tools/maven/apache-maven-3.x, /$AGENT_PATH/swarm-client/swarm-client.jar, /$AGENT_PATH/maven35-interceptor.jar, /$AGENT_PATH/maven3-interceptor-commons.jar, 38414] failed  at hudson.remoting.Channel.call(Channel.java:1004)  at hudson.maven.ProcessCache$MavenProcess.call(ProcessCache.java:161)  at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:877)  at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:526)  at hudson.model.Run.execute(Run.java:1900)  at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)  at hudson.model.ResourceController.execute(ResourceController.java:101)  at hudson.model.Executor.run(Executor.java:442) Caused by: java.lang.LinkageError: loader constraint violation: loader org.codehaus.plexus.classworlds.realm.ClassRealm @445b84c0 wants to load interface org.slf4j.Logger. A different interface with the same name was previously loaded by org.codehaus.plexus.classworlds.realm.ClassRealm @6e3c1e69. (org.slf4j.Logger is in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @6e3c1e69, parent loader 'xxxxxxxxx')  at java.base/java.lang.ClassLoader.defineClass1(Native Method)  at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)  at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)  at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:555)  at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)  at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)  at java.base/java.security.AccessController.doPrivileged(Native Method)  at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)  at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:425)  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 org.apache.maven.cli.event.ExecutionEventLogger.<init>(ExecutionEventLogger.java:65)  at hudson.maven.util.ExecutionEventLogger.<init>(ExecutionEventLogger.java:65)  at hudson.maven.Maven3Builder$MavenExecutionListener.<init>(Maven3Builder.java:375)  at hudson.maven.Maven3Builder$JenkinsEventSpy.<init>(Maven3Builder.java:199)  at hudson.maven.Maven3Builder.call(Maven3Builder.java:119)  at hudson.maven.Maven3Builder.call(Maven3Builder.java:70)  at hudson.remoting.UserRequest.perform(UserRequest.java:211)  at hudson.remoting.UserRequest.perform(UserRequest.java:54)  at hudson.remoting.Request$2.run(Request.java:377)  at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)  at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)  at java.base/java.lang.Thread.run(Thread.java:829) Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to Channel to Maven [/$JAVA_PATH/java, -cp, /data/jenkins/maven35-agent.jar:/$AGENT_PATH/tools/maven/apache-maven-3.x/boot/plexus-classworlds-2.6.0.jar:/$AGENT_PATH/tools/maven/apache-maven-3.x/conf/logging, jenkins.maven3.agent.Maven35Main, /$AGENT_PATH/tools/maven/apache-maven-3.x, /$AGENT_PATH/swarm-client/swarm-client.jar, /$AGENT_PATH/maven35-interceptor.jar, /$AGENT_PATH/maven3-interceptor-commons.jar, 38414]  at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1784)  at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)  at hudson.remoting.Channel.call(Channel.java:1000)  at hudson.maven.ProcessCache$MavenProcess.call(ProcessCache.java:161)  at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:877)  at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:526)  at hudson.model.Run.execute(Run.java:1900)  at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)  at hudson.model.ResourceController.execute(ResourceController.java:101)  at hudson.model.Executor.run(Executor.java:442) ```   Apparently, it is a regression issue that was solved in https://issues.jenkins.io/browse/JENKINS-42098  but was re-introduced in https://issues.jenkins.io/browse/JENKINS-50970 .

          Bolaji added a comment -

          Please is there potential time for the resolution of this problem? Maven projects are currently broken.

          Bolaji added a comment - Please is there potential time for the resolution of this problem? Maven projects are currently broken.

          Hamori added a comment -

          Is there any workaround for this? No one uses maven with swarm?

          Hamori added a comment - Is there any workaround for this? No one uses maven with swarm?

          Mark Waite added a comment - - edited

          This issue and others like it may be one reason why the maven plugin documentation says:

          The Jenkins project recommends that users transition from the Maven job type to use Pipeline jobs or freestyle jobs. Stephen Connolly describes many of the reasons in his 2013 blog post, "Jenkins' Maven job type considered evil". A revised version of that blog post is included here.

          There are multiple ways to build a Maven project with Jenkins:

          • Use a free-style project with a Maven build step
          • Use a Maven-style project
          • Use a Pipeline project with a shell, batch, or powershell build step that calls Maven

          The first way runs the build as Maven intended. The second way adds a whole lot of hooks and can even modify the build in ways that Maven did not intend.

          The first way requires that you configure stuff yourself. The second way tries to "guess" what you want and auto-configure it.

          The first way is initially less user friendly, i.e. you have more UI to click through to get the full set of reports. The second way is initially more user friendly... but when things go wrong... well sorry out of luck.

          If something goes wrong with the first way, worst case you add a shell build step above the Maven build step that just runs SET, trigger a build, login to the build agent, switch to the user the build is running as, apply the environment your SET build step output and then run the Maven command that the build's console log captured. That will give you an exact reproduction of the Maven build and you can debug why your build is not working. When something goes wrong with the second way, well good luck. By all means try to do the same as you would for a freestyle project, but at the end of the day, there is no way you can replicate the injected hooks that Jenkins puts into your Maven build. You can get an approximate reproduction, and hey, that may just be enough to let you figure out what is wrong and fix your build... but there are cases where you cannot.

          It is very attractive because is easy to configure (so users use it) and gives nice per-module reports. When it blows up, and it will blow up, it blows up big.

          Mark Waite added a comment - - edited This issue and others like it may be one reason why the maven plugin documentation says: The Jenkins project recommends that users transition from the Maven job type to use Pipeline jobs or freestyle jobs. Stephen Connolly describes many of the reasons in his 2013 blog post, "Jenkins' Maven job type considered evil" . A revised version of that blog post is included here. There are multiple ways to build a Maven project with Jenkins: Use a free-style project with a Maven build step Use a Maven-style project Use a Pipeline project with a shell, batch, or powershell build step that calls Maven The first way runs the build as Maven intended. The second way adds a whole lot of hooks and can even modify the build in ways that Maven did not intend. The first way requires that you configure stuff yourself. The second way tries to "guess" what you want and auto-configure it. The first way is initially less user friendly, i.e. you have more UI to click through to get the full set of reports. The second way is initially more user friendly... but when things go wrong... well sorry out of luck. If something goes wrong with the first way, worst case you add a shell build step above the Maven build step that just runs SET, trigger a build, login to the build agent, switch to the user the build is running as, apply the environment your SET build step output and then run the Maven command that the build's console log captured. That will give you an exact reproduction of the Maven build and you can debug why your build is not working. When something goes wrong with the second way, well good luck. By all means try to do the same as you would for a freestyle project, but at the end of the day, there is no way you can replicate the injected hooks that Jenkins puts into your Maven build. You can get an approximate reproduction, and hey, that may just be enough to let you figure out what is wrong and fix your build... but there are cases where you cannot. It is very attractive because is easy to configure (so users use it) and gives nice per-module reports. When it blows up, and it will blow up, it blows up big.

          Romain GOUYET added a comment -

          Any news ?
          It's very difficult to use maven jobs with jenkins. Latest jenkins version (> 2.466)  requires "Agent version 3107.v665000b_51092 or newer is required (version 3.40)" 

          As i can't update agent swarm after 3.34 (3028.va_a_436db_35078 )....

          Any workaround ?

          Romain GOUYET added a comment - Any news ? It's very difficult to use maven jobs with jenkins. Latest jenkins version (> 2.466)  requires " Agent version 3107.v665000b_51092 or newer is required (version 3.40)"  As i can't update agent swarm after 3.34 (3028.va_a_436db_35078 ).... Any workaround ?

          Paul Swarts added a comment -

          Any news?

          Paul Swarts added a comment - Any news?

            Unassigned Unassigned
            pswarts Paul Swarts
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: