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

Prepare SLOCCount for removal of JAXB and Java 11 requirement

    XMLWordPrintable

Details

    • 1.26

    Description

      As described in Dependencies and Class Loading:

      Java defines a Thread.getContextClassLoader(). Jenkins does not use this much; it will normally be set by the servlet container to the Jenkins core loader.

      Unfortunately, JAXB has a design flaw in that JAXBContext#newInstance expects JAXB to be available in the thread's context class loader. With JAXB being detached to a separate plugin as of recent Java 11 changes, JAXB is no longer available in the Jenkins core loader. This causes a failure to load JAXB.

      This plugin has been identified as containing such a call to JAXBContext#newInstance The suggested solution is to wrap calls to JAXBContext#newInstance with a try/finally block to set the thread's context class loader to that of the plugin, which (by virtue of a plugin-to-plugin dependency on JAXB API plugin) enables JAXB to be loaded. See the following PR for an example:

      https://github.com/jenkinsci/xcode-plugin/pull/113/files

      Attachments

        Issue Links

          Activity

            varshithas Varshitha s added a comment -

            I still face the same issue that slocc plugin throws a java error and JAXBException as mentioned in JENKINS-55620 even after the slocc plugin is updated to the latest version 1.26.
            Please find the below screenshot of the error. 

            varshithas Varshitha s added a comment - I still face the same issue that slocc plugin throws a java error and JAXBException as mentioned in JENKINS-55620 even after the slocc plugin is updated to the latest version 1.26. Please find the below screenshot of the error. 
            basil Basil Crow added a comment -

            Fixed in jenkinsci/sloccount-plugin#62. Released in 1.26.

            basil Basil Crow added a comment - Fixed in jenkinsci/sloccount-plugin#62 . Released in 1.26 .
            basil Basil Crow added a comment -
            basil Basil Crow added a comment - CC imarinkov

            I created https://github.com/jenkinsci/sloccount-plugin/pull/62 to fix the code and use the proper classLoader.

            alecharp Adrien Lecharpentier added a comment - I created https://github.com/jenkinsci/sloccount-plugin/pull/62 to fix the code and use the proper classLoader.
            basil Basil Crow added a comment - https://github.com/jenkinsci/sloccount-plugin/blob/e3edcd2d5d01f0000bc33c16d6ca736bd8349913/src/main/java/hudson/plugins/sloccount/model/cloc/ClocReport.java#L57-L68= needs to be wrapped to set the thread's context classloader.

            People

              alecharp Adrien Lecharpentier
              basil Basil Crow
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: