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

Git Plugin 3.3.0 with Maven Plugin 2.15.1 causes TypeNotPresentException in RemoteClassLoader

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • git-plugin, maven-plugin
    • None
    • Jenkins 2.55, Git Plugin 3.3.0, Maven Plugin 2.15.1

      Problem: The Git Plugin org.jenkins-ci.plugins:git:3.3.0 can cause a java.lang.TypeNotPresentException exception in the RemoteClassLoader when using the Maven Plugin org.jenkins-ci.main:maven-plugin:2.15.1. I encountered the problem in my custom plugin when a FileCallable attempted to execute a MavenEmbedderRequest on a slave. Stack trace is attached.

      The problem seems to be the inclusion in the HPI of an outdated and unnecessary transitive dependency (aether-*:0.9.0.M2) of a non-included, optional dependency (promoted-builds:2.27). If this is correct, a fix is the addition of an exclusion in the POM.

      Scope: This problem affects any plugin attempting to execute a MavenEmbedderRequest on a slave.

      Aside: It seems odd to me that the maven-hpi-plugin would include a transitive dependency of a dependency that is not included. Could you please comment on what you see as the root cause of this problem.

      Analysis:

      1.) The optional dependency org.jenkins-ci.plugins:promoted-builds:2.27 introduces a transitive dependency on org.eclipse.aether:aether-connector-wagon:0.9.0.M2. The exact dependency chain is: org.jenkins-ci.plugins:git:3.3.0 > org.jenkins-ci.plugins:promoted-builds:2.27 > maven-plugin:2.0 > maven-core:3.0 > aether-*:0.9.0.M2.

      As a result, aether-connector-wagon-0.9.0.M2.jar is included in the git plugin HPI, while promoted-builds-2.27.jar is not. The aether-connector-wagon classes are not needed at compile time and are only needed at runtime when the non-included promoted-builds classes are also needed. The promoted-build dependency is required at compile time only for the class GitRevisionBuildParameters which checks for the presence of the promoted-builds plugin.

      2.) The aether-:0.9.0.M2 line is outdated and recent versions of the maven-plugin use aether-:1.1.0. The aether-*:1.1.0 line no longer has org.eclipse.aether.connector.wagon.WagonRepositoryConnectorFactory, for example.

      3.) When using org.jenkins-ci.plugins:git:3.3.0 and org.jenkins-ci.main:maven-plugin:2.15.1, a classloader may find org.eclipse.aether.connector.wagon.WagonRepositoryConnectorFactory which is annotated with @Component( role = RepositoryConnectorFactory.class, hint = "wagon" ). The attempt by RemoteClassLoader to instantiate the class remotely then yields a TypeNotPresentException.

      4.) Regarding the may qualification in (3), the problem is not deterministic from the user's GUI perspective. The error occurrs with high probability, but some builds succeeded as well depending, I assume, on prior build, poll etc. events.

      Solution:

      The addition of an exclusion on the optional promoted-builds dependency fixes this problem. In the org.jenkins-ci.plugins:git:3.3.1-SNAPSHOT POM, expand this:

      <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>promoted-builds</artifactId>
      <version>2.27</version>
      <optional>true</optional>
      <exclusions>
      <exclusion>
      <groupId>org.sonatype.sisu</groupId>
      <artifactId>sisu-guava</artifactId>
      </exclusion>
      </exclusions>
      </dependency>

      to that:

      <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>promoted-builds</artifactId>
      <version>2.27</version>
      <optional>true</optional>
      <exclusions>
      <exclusion>
      <groupId>org.sonatype.sisu</groupId>
      <artifactId>sisu-guava</artifactId>
      </exclusion>
      <exclusion>
      <groupId>org.jenkins-ci.main</groupId>
      <artifactId>maven-plugin</artifactId>
      </exclusion>
      </exclusions>
      </dependency>

      The resulting git-plugin HPI keeps the following jars:

      annotation-indexer-1.4.jar
      bridge-method-annotation-1.15.jar
      git.jar
      joda-time-2.9.5.jar

      Compared to the unmodified org.jenkins-ci.plugins:git:3.3.1-SNAPSHOT, it dropps the following jars:

      aether-connector-wagon-0.9.0.M2.jar
      cdi-api-1.0.jar
      commons-codec-1.9.jar
      httpcore-4.4.4.jar
      jsr250-api-1.0.jar
      lib-jenkins-maven-embedder-3.11.jar
      maven-artifact-3.1.0.jar
      org.eclipse.sisu.inject-0.1.0.jar
      org.eclipse.sisu.plexus-0.1.0.jar
      plexus-component-annotations-1.5.5.jar
      plexus-utils-2.1.jar

       

            Unassigned Unassigned
            mtthshld1 Matthias Hild
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: