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

SloccountPublisher fails on Java 11 without --add-modules java.xml.bind

    • JAXB Plugin

      Using a Jenkins running on Java 11 (Java 11 support is currently in preview (https://jenkins.io/blog/2018/12/14/java11-preview-availability/), SloccountPublisher throws the following exception while generating the report.

      janv. 16, 2019 2:26:14 PM hudson.model.AbstractBuild$AbstractBuildExecution reportError
      WARNING: Step ‘Publish SLOCCount analysis results’ aborted due to exception: 
      java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
              at hudson.plugins.sloccount.SloccountPublisher.perform(SloccountPublisher.java:82)
              at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
              at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
              at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
              at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
              at hudson.model.Build$BuildExecution.post2(Build.java:186)
              at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
              at hudson.model.Run.execute(Run.java:1835)
              at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
              at hudson.model.ResourceController.execute(ResourceController.java:97)
              at hudson.model.Executor.run(Executor.java:429)
      Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
              at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1374)
              at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1327)
              at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1080)
              at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
              ... 11 more
      

      Expected behavior

      Though there is ongoing work to see how/if to keep making JAXB usages in Jenkins on Java 11+, it would be nice if the plugin code could be analyzed to see if it could work without depending on JAXB API (which has been removed from the JDK starting from Java 9+).

      Technical consideration

      Looking at the code quickly, I think the main (only?) reason JAXB usage is to marshall/unmarshall the ClocReport.

      I think replacing the serialization with an XStream marshalling would probably achieve the same thing, while removing the JAXB dependency.

          [JENKINS-55620] SloccountPublisher fails on Java 11 without --add-modules java.xml.bind

          the PR is proposing a fix, which implies releasing the new JAXB plugin (JENKINS-55681).

          I created a dedicated Docker image for anyone to test this easily https://github.com/batmat/jaxb-java11-demo

          Baptiste Mathus added a comment - the PR is proposing a fix, which implies releasing the new JAXB plugin ( JENKINS-55681 ). I created a dedicated Docker image for anyone to test this easily https://github.com/batmat/jaxb-java11-demo

          Oleg Nenashev added a comment -

          Fixed by the JAXB Plugin

          Oleg Nenashev added a comment - Fixed by the JAXB Plugin

          Brian Walker added a comment -

          I could not get this to work on e JAVA 11 worker node (main Jenkins node is running Java 8).  I ended up forking the GitHub repo and using xstream instead of JAXB. That version works on Jenkins worker nodes running either Java 8 or Java 11.

          Brian Walker added a comment - I could not get this to work on e JAVA 11 worker node (main Jenkins node is running Java 8).  I ended up forking the GitHub repo and using xstream instead of JAXB. That version works on Jenkins worker nodes running either Java 8 or Java 11.

          daddyman what error did you get?

          Also, IIUC you mean you're running the controller (fka "master") with a major Java version that's different from the agent (that you call "worker node" in your comment?). If so, please beware that's a strongly discouraged setup : it will seem to work, but will fail badly in subtle manners (sometimes hard to diagnose). For your mental health it's warmly recommended to use the same major version on all nodes .

          Baptiste Mathus added a comment - daddyman what error did you get? Also, IIUC you mean you're running the controller (fka "master") with a major Java version that's different from the agent (that you call "worker node" in your comment?). If so, please beware that's a strongly discouraged setup : it will seem to work, but will fail badly in subtle manners (sometimes hard to diagnose). For your mental health it's warmly recommended to use the same major version on all nodes .

          Jean-Luc Pé added a comment - - edited

          Dear all,

          I have a Jenkins 2.263.3 master running on an alpine based container with openjdk version "1.8.0_262" (it is a jenkins/jenkins:lts-alpine based container).

          • sloccountPublisher plugin is at the latest version : 1.24
          • jaxb plugin is also installed at the latest version : 2.3.0.1
          • On a slave running within a container based on debian:jessie with openjdk 1.8.0_171, sloccountPublisher runs OK.
          • On a slave running within a container based on debian:buster with openjdk 11.0.9., sloccountPublisher fails with the java.lang.ClassNotFoundException: javax.xml.bind.JAXBException.

          So... I think I could be in the same situation as described by Brian Walker.
          And... if such a  situation is discouraged and the JAXB plugin fix does not work, could it be possible to have a workaround as proposed in the "Technical Consideration" section ?

          The point is that as fas ar  official jenkins LTS images (jenkins/jenkins:lts-alpine, and debian based as well) are running such an old java version (ENV JAVA_VERSION=jdk8u275-b01), there is a wide number of situation where nodes will have different (much more recent) java version.

          Jean-Luc Pé added a comment - - edited Dear all, I have a Jenkins 2.263.3 master running on an alpine based container with openjdk version "1.8.0_262" (it is a jenkins/jenkins:lts-alpine based container). sloccountPublisher plugin is at the latest version : 1.24 jaxb plugin is also installed at the latest version : 2.3.0.1 On a slave running within a container based on debian:jessie with openjdk 1.8.0_171, sloccountPublisher runs OK. On a slave running within a container based on debian:buster with openjdk 11.0.9., sloccountPublisher fails with the java.lang.ClassNotFoundException: javax.xml.bind.JAXBException. So... I think I could be in the same situation as described by Brian Walker. And... if such a  situation is discouraged and the JAXB plugin fix does not work, could it be possible to have a workaround as proposed in the "Technical Consideration" section ? The point is that as fas ar  official jenkins LTS images (jenkins/jenkins:lts-alpine, and debian based as well) are running such an old java version (ENV JAVA_VERSION=jdk8u275-b01), there is a wide number of situation where nodes will have different (much more recent) java version.

          Basil Crow added a comment -

          Now being tracked in JENKINS-68514.

          Basil Crow added a comment - Now being tracked in JENKINS-68514 .

            npiguet npiguet
            batmat Baptiste Mathus
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: