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

com.sonyericsson.jenkins.plugins.bfa.model.dbf.ParameterizedTriggerDBF uses wrong ClassLoader to detect hudson.plugins.parameterizedtrigger.BuildInfoExporterAction

    XMLWordPrintable

Details

    Description

      com.sonyericsson.jenkins.plugins.bfa.model.dbf.ParameterizedTriggerDBF mentions We want to avoid having dependencies to other plugins thus using reflection., that means checking for hudson.plugins.parameterizedtrigger.BuildInfoExporterAction using the current classloader (Class.forName(className)) will never return anything since Jenkins isolate plugins classloaders.

      This causes the feature (extract failure from downstream) not to work and produces the following error to be logged:

      Jan 19, 2016 7:05:44 PM FINER com.sonyericsson.jenkins.plugins.bfa.model.dbf.ParameterizedTriggerDBF

      Class hudson.plugins.parameterizedtrigger.BuildInfoExporterAction not installed. Can't get downstream builds

      The following Groovy script (you can paste it in $JENKINS_HOME/script)

      jenkins.model.Jenkins.instance.with { jenkins ->
        pluginManager.with {
          final String className = 'hudson.plugins.parameterizedtrigger.BuildInfoExporterAction'
      
          [getPlugin('build-failure-analyzer').classLoader, uberClassLoader].each {
            try {
              out.println "Attempting to load with ${it}"
              final Class clazz = it.loadClass(className)
              out.println "Loaded from actual classloader: ${clazz.classLoader}"
            } catch (ClassNotFoundException e) {
              out.println "Class not found: ${e.message}"
            }
          }
        }
      }
      null
      

      shows the following output:

      Attempting to load with AntClassLoader[/var/lib/jenkins/plugins/build-failure-analyzer/WEB-INF/lib/jsr305-1.3.9.jar:/var/lib/jenkins/plugins/build-failure-analyzer/WEB-INF/lib/mongo-jackson-mapper-1.4.1.jar:/var/lib/jenkins/plugins/build-failure-analyzer/WEB-INF/lib/build-failure-analyzer.jar:/var/lib/jenkins/plugins/build-failure-analyzer/WEB-INF/lib/persistence-api-1.0.2.jar:/var/lib/jenkins/plugins/build-failure-analyzer/WEB-INF/lib/bson4jackson-1.3.0.jar:/var/lib/jenkins/plugins/build-failure-analyzer/WEB-INF/lib/jackson-core-asl-1.9.6.jar:/var/lib/jenkins/plugins/build-failure-analyzer/WEB-INF/lib/guava-11.0.1.jar:/var/lib/jenkins/plugins/build-failure-analyzer/WEB-INF/lib/jackson-mapper-asl-1.9.6.jar:/var/lib/jenkins/plugins/build-failure-analyzer/WEB-INF/lib/mongo-java-driver-2.11.2.jar]
      Class not found: hudson.plugins.parameterizedtrigger.BuildInfoExporterAction
      Attempting to load with classLoader hudson.PluginManager$UberClassLoader
      Loaded from actual classloader: AntClassLoader[/var/lib/jenkins/plugins/parameterized-trigger/WEB-INF/lib/parameterized-trigger.jar:/var/lib/jenkins/plugins/parameterized-trigger/WEB-INF/lib/xercesImpl-2.9.1.jar]
      

      As you can see, BFA cannot use its own classloader to look for another plugin class even though it is present (which defeats the purpose of announcing bypassing Jenkins dependency resolution).

      Could you please consider:

      • declaring parameterizedtrigger as optional dependency to make the class available for that DBF to work as intended
      • or using another classloader to look for that specific class

      Attachments

        Activity

          fchuong Frédéric Chuong created issue -
          t_westling Tomas Westling added a comment - - edited

          Good find!
          I think the best solution is just to remove the <scope>test</scope> from the dependency in the pom
          since there is already a test dependency set as optional for parameterized-trigger.

          Since there is a test dependency, this would hint at why this issue didn't cause any tests to fail.

          t_westling Tomas Westling added a comment - - edited Good find! I think the best solution is just to remove the <scope>test</scope> from the dependency in the pom since there is already a test dependency set as optional for parameterized-trigger. Since there is a test dependency, this would hint at why this issue didn't cause any tests to fail.
          rtyler R. Tyler Croy made changes -
          Field Original Value New Value
          Workflow JNJira [ 168271 ] JNJira + In-Review [ 183043 ]
          mdiehn Mike Diehn made changes -
          Link This issue relates to JENKINS-48721 [ JENKINS-48721 ]
          mdiehn Mike Diehn made changes -
          Link This issue relates to JENKINS-48721 [ JENKINS-48721 ]
          mdiehn Mike Diehn made changes -
          Link This issue relates to JENKINS-49140 [ JENKINS-49140 ]
          mdiehn Mike Diehn made changes -
          Link This issue relates to JENKINS-49140 [ JENKINS-49140 ]

          People

            t_westling Tomas Westling
            fchuong Frédéric Chuong
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: