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

java.lang.NoClassDefFoundError if rabbitmq-consumer plugin is not installed

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Blocker
    • Resolution: Fixed
    • gerrit-trigger-plugin
    • None
    • Jenkins 1.651.2
      Gerrit-trigger: 2.21.0

    Description

      I get the following exception in the the latest update of gerrit trigger plugin:

      Jun 02, 2016 7:38:09 PM com.sonymobile.tools.gerrit.gerritevents.GerritHandler notifyListener
      SEVERE: Exception thrown during event handling.
      java.lang.reflect.InvocationTargetException
                      at sun.reflect.GeneratedMethodAccessor471.invoke(Unknown Source)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                      at java.lang.reflect.Method.invoke(Method.java:606)
                      at com.sonymobile.tools.gerrit.gerritevents.GerritHandler.notifyListener(GerritHandler.java:316)
                      at com.sonymobile.tools.gerrit.gerritevents.GerritHandler.notifyListeners(GerritHandler.java:296)
                      at com.sonyericsson.hudson.plugins.gerrit.trigger.JenkinsAwareGerritHandler.notifyListeners(JenkinsAwareGerritHandler.java:77)
                      at com.sonymobile.tools.gerrit.gerritevents.workers.AbstractGerritEventWork.perform(AbstractGerritEventWork.java:46)
                      at com.sonymobile.tools.gerrit.gerritevents.workers.GerritEventWork.perform(GerritEventWork.java:48)
                      at com.sonymobile.tools.gerrit.gerritevents.workers.EventThread.run(EventThread.java:66)
                      at com.sonyericsson.hudson.plugins.gerrit.trigger.SystemEventThread.run(SystemEventThread.java:66)
      Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
                      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener$ParametersActionInspection.<init>(EventListener.java:435)
                      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener.getParametersInspection(EventListener.java:391)
                      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener.createParameters(EventListener.java:269)
                      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener.schedule(EventListener.java:188)
                      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener.schedule(EventListener.java:164)
                      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener.gerritEvent(EventListener.java:126)
                      ... 10 more
      Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
                      at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1376)
                      at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1326)
                      at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1079)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      

      It looks like in the following commit the dependency to apache commons lang 3 was introduced:
      https://github.com/jenkinsci/gerrit-trigger-plugin/pull/285/files#diff-54e50e5c447d3a893fd786bd419ee8b4R46

      This dependency is resolved during build time via the rabbitmq-consumer plugin. Since this plugin is optional, the class will not be found if this plugin is not installed.
      There are now two possibilities to fix this (which is why I didn't create a pull request in the first place):

      1. Replace in class 'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener' the import 'org.apache.commons.lang3.StringUtils' with 'org.apache.commons.lang.StringUtils'. This class is available with core jenkins installation.
      2. Explicitely add apache commons-lang3 to the dependencies of gerrit trigger plugin to make sure it is always imported.

      Attachments

        Activity

          unguiculus unguiculus added a comment -

          We just discoverd this as well. I created a pull request using the first solution as suggested above.

          https://github.com/jenkinsci/gerrit-trigger-plugin/pull/286

          unguiculus unguiculus added a comment - We just discoverd this as well. I created a pull request using the first solution as suggested above. https://github.com/jenkinsci/gerrit-trigger-plugin/pull/286
          rin_ne rin_ne added a comment -

          rabbitmq-consumer has dependency to commons-lang3 explicitly. Jenkins core has dependency to commons-lang, but commons-lang3.
          but according to comment in core's pom.xml, core itself does not use it. Means it is added as workaround for some plugins.
          (Actually, Jenkins core has no dependency to it when I started to implement rabbitmq-consumer)

          So I think plugin should have dependency to commons-lang or commons-lang3. Thus better solution is 2, I think.

          rin_ne rin_ne added a comment - rabbitmq-consumer has dependency to commons-lang3 explicitly. Jenkins core has dependency to commons-lang, but commons-lang3. but according to comment in core's pom.xml, core itself does not use it. Means it is added as workaround for some plugins. (Actually, Jenkins core has no dependency to it when I started to implement rabbitmq-consumer) So I think plugin should have dependency to commons-lang or commons-lang3. Thus better solution is 2, I think.

          Code changed in jenkins
          User: Reinhard Naegele
          Path:
          src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/EventListener.java
          src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritProjectListUpdaterFunctionalTest.java
          src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/TestUtils.java
          http://jenkins-ci.org/commit/gerrit-trigger-plugin/78ae1463453032c985aef72d9eafafd52dc97f40
          Log:
          JENKINS-35364 Fix use of StringUtils

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Reinhard Naegele Path: src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/EventListener.java src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritProjectListUpdaterFunctionalTest.java src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/TestUtils.java http://jenkins-ci.org/commit/gerrit-trigger-plugin/78ae1463453032c985aef72d9eafafd52dc97f40 Log: JENKINS-35364 Fix use of StringUtils

          Code changed in jenkins
          User: Robert Sandell
          Path:
          src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/EventListener.java
          src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritProjectListUpdaterFunctionalTest.java
          src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/TestUtils.java
          http://jenkins-ci.org/commit/gerrit-trigger-plugin/33957ae997ed2cb7e6a491c113395b5a9d1b0d46
          Log:
          Merge pull request #286 from unguiculus/JENKINS-35364

          JENKINS-35364 Fix use of StringUtils

          Compare: https://github.com/jenkinsci/gerrit-trigger-plugin/compare/395a89f20c69...33957ae997ed

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/EventListener.java src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritProjectListUpdaterFunctionalTest.java src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/mock/TestUtils.java http://jenkins-ci.org/commit/gerrit-trigger-plugin/33957ae997ed2cb7e6a491c113395b5a9d1b0d46 Log: Merge pull request #286 from unguiculus/ JENKINS-35364 JENKINS-35364 Fix use of StringUtils Compare: https://github.com/jenkinsci/gerrit-trigger-plugin/compare/395a89f20c69...33957ae997ed
          schristou Steven Christou added a comment - Fixed in version 2.21.1: https://github.com/jenkinsci/gerrit-trigger-plugin/commit/33957ae997ed2cb7e6a491c113395b5a9d1b0d46 .

          People

            rsandell rsandell
            felixw Felix Wohlfrom
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: