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

processMavenSpyLogs can fail with "java.lang.IllegalAccessError: tried to access method"

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • pipeline-maven-plugin
    • None
    • Jenkins Core 2.107.x
      Maven-pipeline 3.5.6

      Issue:
      When running a maven process inside of a build an error popped up saying

      java.lang.IllegalAccessError: tried to access method org.apache.xerces.parsers.XML11Configuration.getFeature0(Ljava/lang/String;)Z from class org.apache.xerces.parsers.XIncludeAwareParserConfiguration 
      at org.apache.xerces.parsers.XIncludeAwareParserConfiguration.getFeature(Unknown Source) 
      at org.apache.xerces.parsers.AbstractDOMParser.reset(Unknown Source) 
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) 
      at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) 
      at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) 
      at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) 
      at org.jenkinsci.plugins.pipeline.maven.MavenSpyLogProcessor.processMavenSpyLogs(MavenSpyLogProcessor.java:97) 
      at org.jenkinsci.plugins.pipeline.maven.WithMavenStepExecution$WithMavenStepExecutionCallBack.finished(WithMavenStepExecution.java:1050) 
      

      It seems to come from the code here:
      https://github.com/jenkinsci/pipeline-maven-plugin/blob/1729e64250c10213ca428141092540bdeeaba97a/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenSpyLogProcessor.java#L97

      Steps to reproduce:
      I have not been able to narrow down why it is unable to load a library so it happened with one job but not with others.

      Workaround:
      Disable the spy event entirely with `JENKINS_MAVEN_AGENT_DISABLED = true `

          [JENKINS-51404] processMavenSpyLogs can fail with "java.lang.IllegalAccessError: tried to access method"

          Thanks drulli.
          Investigating more on this "IllegalAccessError: tried to access method..." exception, I feel the problem is probably more caused by o.a.x.p. XIncludeAwareParserConfiguration and o.a.x.p. XML11Configuration NOT being loaded by the same class loader.

          Cyrille Le Clerc added a comment - Thanks drulli . Investigating more on this "IllegalAccessError: tried to access method..." exception, I feel the problem is probably more caused by o.a.x.p. XIncludeAwareParserConfiguration and o.a.x.p. XML11Configuration NOT being loaded by the same class loader.

          ataylor can you please get more details on the classloaders that have loaded the following classes: "org.apache.xerces.parsers.XIncludeAwareParserConfiguration", "org.apache.xerces.parsers.XML11Configuration"?

          I want to verify that all the Xerces classes are loaded by the same classloader.

          Can you executing the following script?

          Collection<String> classNames = Arrays.asList("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl", "org.apache.xerces.parsers.XIncludeAwareParserConfiguration", "org.apache.xerces.parsers.XML11Configuration")
          
          
          for (String className: classNames) {
           
            Class klass
            try {
              klass = Class.forName(className)
            } catch (Exception e) {
              println("Exception trying to load " + className + " from the system classloader, try the thread context classloader " + e)
              // contextClassLoader should not work but let's try it.
              klass = Class.forName(className, false, Thread.currentThread().getContextClassLoader())
            }
             
            java.security.CodeSource codeSource = klass.getProtectionDomain().getCodeSource()
             
            if (codeSource == null) {
              println(klass.toString() + " (classLoader:" + klass.getClassLoader() + ")  -> source not found")
            } else {
              println(klass.toString()  + " (classLoader:" + klass.getClassLoader() + ")  -> " + codeSource.getLocation());
            }
          }
          

          Cyrille Le Clerc added a comment - ataylor can you please get more details on the classloaders that have loaded the following classes: "org.apache.xerces.parsers.XIncludeAwareParserConfiguration", "org.apache.xerces.parsers.XML11Configuration"? I want to verify that all the Xerces classes are loaded by the same classloader. Can you executing the following script? Collection< String > classNames = Arrays.asList( "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl" , "org.apache.xerces.parsers.XIncludeAwareParserConfiguration" , "org.apache.xerces.parsers.XML11Configuration" ) for ( String className: classNames) { Class klass try { klass = Class .forName(className) } catch (Exception e) { println( "Exception trying to load " + className + " from the system classloader, try the thread context classloader " + e) // contextClassLoader should not work but let's try it. klass = Class .forName(className, false , Thread .currentThread().getContextClassLoader()) } java.security.CodeSource codeSource = klass.getProtectionDomain().getCodeSource() if (codeSource == null ) { println(klass.toString() + " (classLoader:" + klass.getClassLoader() + ") -> source not found" ) } else { println(klass.toString() + " (classLoader:" + klass.getClassLoader() + ") -> " + codeSource.getLocation()); } }

          Alex Taylor added a comment -

          @Cyrille

          Return of the script is:

          class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl (classLoader:AntClassLoader[/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/cglib-2.2.2.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/analysis-core.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-beanutils-1.8.3.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-digester3-3.2.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-lang3-3.4.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/joda-time-2.9.5.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/xml-apis-1.4.01.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/java2html-5.0.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/asm-3.3.1.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/xercesImpl-2.11.0.jar]) -> file:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/xercesImpl-2.11.0.jar 
          class org.apache.xerces.parsers.XIncludeAwareParserConfiguration (classLoader:AntClassLoader[/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/cglib-2.2.2.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/analysis-core.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-beanutils-1.8.3.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-digester3-3.2.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-lang3-3.4.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/joda-time-2.9.5.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/xml-apis-1.4.01.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/java2html-5.0.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/asm-3.3.1.jar:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/xercesImpl-2.11.0.jar]) -> file:/var/lib/jenkins/plugins/analysis-core/WEB-INF/lib/xercesImpl-2.11.0.jar 
          class org.apache.xerces.parsers.XML11Configuration (classLoader:AntClassLoader[/var/lib/jenkins/plugins/findbugs/WEB-INF/lib/cglib-2.2.2.jar:/var/lib/jenkins/plugins/findbugs/WEB-INF/lib/groovy-sandbox-1.10.jar:/var/lib/jenkins/plugins/findbugs/WEB-INF/lib/commons-beanutils-1.8.3.jar:/var/lib/jenkins/plugins/findbugs/WEB-INF/lib/commons-digester3-3.2.jar:/var/lib/jenkins/plugins/findbugs/WEB-INF/lib/findbugs.jar:/var/lib/jenkins/plugins/findbugs/WEB-INF/lib/library-2.0.4.jar:/var/lib/jenkins/plugins/findbugs/WEB-INF/lib/asm-3.3.1.jar]) -> file:/var/lib/jenkins/plugins/findbugs/WEB-INF/lib/library-2.0.4.jar
          

          Let me know if that helps

          Alex Taylor added a comment - @Cyrille Return of the script is: class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl (classLoader:AntClassLoader[/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/cglib-2.2.2.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/analysis-core.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-beanutils-1.8.3.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-digester3-3.2.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-lang3-3.4.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/joda-time-2.9.5.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/xml-apis-1.4.01.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/java2html-5.0.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/asm-3.3.1.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/xercesImpl-2.11.0.jar]) -> file:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/xercesImpl-2.11.0.jar class org.apache.xerces.parsers.XIncludeAwareParserConfiguration (classLoader:AntClassLoader[/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/cglib-2.2.2.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/analysis-core.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-beanutils-1.8.3.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-digester3-3.2.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/commons-lang3-3.4.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/joda-time-2.9.5.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/xml-apis-1.4.01.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/java2html-5.0.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/asm-3.3.1.jar:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/xercesImpl-2.11.0.jar]) -> file:/ var /lib/jenkins/plugins/analysis-core/WEB-INF/lib/xercesImpl-2.11.0.jar class org.apache.xerces.parsers.XML11Configuration (classLoader:AntClassLoader[/ var /lib/jenkins/plugins/findbugs/WEB-INF/lib/cglib-2.2.2.jar:/ var /lib/jenkins/plugins/findbugs/WEB-INF/lib/groovy-sandbox-1.10.jar:/ var /lib/jenkins/plugins/findbugs/WEB-INF/lib/commons-beanutils-1.8.3.jar:/ var /lib/jenkins/plugins/findbugs/WEB-INF/lib/commons-digester3-3.2.jar:/ var /lib/jenkins/plugins/findbugs/WEB-INF/lib/findbugs.jar:/ var /lib/jenkins/plugins/findbugs/WEB-INF/lib/library-2.0.4.jar:/ var /lib/jenkins/plugins/findbugs/WEB-INF/lib/asm-3.3.1.jar]) -> file:/ var /lib/jenkins/plugins/findbugs/WEB-INF/lib/library-2.0.4.jar Let me know if that helps

          org.apache.xerces.parsers.XML11Configuration is loaded by the Findbugs plugin which loads Xerces 2.9.1 (see here) when the desired Xerces version is 2.11.0.
          Note that I don't understand how this can happen. There are many master using FindBugs that don't face this problem.

          Cyrille Le Clerc added a comment - org.apache.xerces.parsers.XML11Configuration is loaded by the Findbugs plugin which loads Xerces 2.9.1 (see here ) when the desired Xerces version is 2.11.0. Note that I don't understand how this can happen. There are many master using FindBugs that don't face this problem.

          Ulli Hafner added a comment -

          I finally removed the Xerces dependency from the findbugs parser. It is released in the beta of the new warnings plugin. Is it important to release it in the old and deprecated findbugs plugin as well?

          BTW: are reporting plugins like findbugs and warnings automatically supported by the the pipeline maven plugin or do you to hard-code these tools?

          Ulli Hafner added a comment - I finally removed the Xerces dependency from the findbugs parser. It is released in the beta of the new warnings plugin . Is it important to release it in the old and deprecated findbugs plugin as well? BTW: are reporting plugins like findbugs and warnings automatically supported by the the pipeline maven plugin or do you to hard-code these tools?

          drulli thanks, if you could by any chance cut a version of the "old findbugs plugin", it would help the transition to the new world.

          Cyrille Le Clerc added a comment - drulli thanks, if you could by any chance cut a version of the "old findbugs plugin", it would help the transition to the new world.

          Ulli Hafner added a comment -

          I released findbugs-5.0.0-beta3 now, that contains the findbugs library with Xerces 2.11.0.

          Note: It would still be quite helpful to find the actual plugin (or tool?) that sets the sax property globally! I added some logging to the warnings plugin now to see if the sax property has been altered.

          Ulli Hafner added a comment - I released findbugs-5.0.0-beta3 now, that contains the findbugs library with Xerces 2.11.0. Note: It would still be quite helpful to find the actual plugin (or tool?) that sets the sax property globally! I added some logging to the warnings plugin now to see if the sax property has been altered.

          > I released findbugs-5.0.0-beta3 now, that contains the findbugs library with Xerces 2.11.0.

          Thanks drulli!

          > Note: It would still be quite helpful to find the actual plugin (or tool?) that sets the sax property globally! I added some logging to the warnings plugin now to see if the sax property has been altered.

          I am not aware of such problem. Is it the reason why you import Xerces in the findbugs plugin?

          Cyrille Le Clerc added a comment - > I released findbugs-5.0.0-beta3 now, that contains the findbugs library with Xerces 2.11.0. Thanks drulli ! > Note: It would still be quite helpful to find the actual plugin (or tool?) that sets the sax property globally! I added some logging to the warnings plugin now to see if the sax property has been altered. I am not aware of such problem. Is it the reason why you import Xerces in the findbugs plugin?

          Ulli Hafner added a comment -

          Yes, this is the only reason. FindBugs uses XMLReaderFactory to obtain a parser. Normally this is the JDK parser. However, someone (plugin, system configuration, container, etc.?) seems to override one of the SAX settings (system property or Service Locator) and defines Xerces as default.

          Ulli Hafner added a comment - Yes, this is the only reason. FindBugs uses XMLReaderFactory to obtain a parser. Normally this is the JDK parser. However, someone (plugin, system configuration, container, etc.?) seems to override one of the SAX settings (system property or Service Locator) and defines Xerces as default.

          Understood. I am sorry but I have no clue of who could do this.

          Cyrille Le Clerc added a comment - Understood. I am sorry but I have no clue of who could do this.

            Unassigned Unassigned
            ataylor Alex Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: