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

Findbugs messes with the XML parser causing M2 builds to fail

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Component/s: findbugs-plugin
    • Labels:
      None
    • Environment:
      Static Analysis Collector Plug: 1.8
      Static Analysis Utilities: 1.14
      FindBugs Plug-in: 4.14
      Hudson: 1.381
    • Similar Issues:

      Description

      The Findbugs plugin sets the system varaible to the a non standard sax parser.

      It helpfully adds the sax parser to its context classpath.

      When some part of a maven build wishes to use a sax parser it blows up as it can not load the non-existent sax parser.

      Findbugs should not set the sax parser and use whatever is returned using the standard JDK APIs.

      INFO] Generating "Project Summary" report.
      [INFO] Generating "About" report.
      [INFO] Generating "FindBugs Report" report.
      [INFO] Using source root:
      [INFO] /home/hudson/data/workspace/xxx-app_full/trunk/xxx-app-common/xxx-app-common-core/target/classes
      [INFO] Using test source root:
      [INFO] /home/hudson/data/workspace/xxx-app_full/trunk/xxx-app-common/xxx-app-common-core/target/test-classes
      [INFO] Using maximum effort.
      [INFO] Adding Source Directory: /home/hudson/data/workspace/xxx-app_full/trunk/xxx-app-common/vam-app-common-core/src/main/java
      [INFO] Using low threshold.
      [INFO] Using FindBugs Version: 1.3.7
      [INFO] Using low threshold.
      [INFO] Using low threshold.
      [INFO] Using low threshold.
      [INFO] Using the xdoc format
      [INFO] Using maximum effort.
      [INFO] Using low threshold.
      [INFO] Using low threshold.
      [INFO] Debugging is Off
      [INFO] No bug include filter.
      [INFO] Using bug exclude filter /tmp/plexus-resources178441232tmp
      [INFO] ------------------------------------------------------------------------
      [ERROR] FATAL ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] A java source file could not be added

      Embedded error: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
      [INFO] ------------------------------------------------------------------------
      [INFO] Trace
      java.lang.reflect.UndeclaredThrowableException
      at $Proxy10.generate(Unknown Source)
      at org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:139)
      at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderModule(DefaultSiteRenderer.java:303)
      at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render(DefaultSiteRenderer.java:135)
      at org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:133)
      at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:100)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
      at hudson.maven.agent.PluginManagerInterceptor.executeMojo(PluginManagerInterceptor.java:182)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
      at org.apache.maven.lifecycle.LifecycleExecutorInterceptor.execute(LifecycleExecutorInterceptor.java:65)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at hudson.maven.agent.Main.launch(Main.java:165)
      at hudson.maven.MavenBuilder.call(MavenBuilder.java:165)
      at hudson.maven.MavenModuleSetBuild$Builder.call(MavenModuleSetBuild.java:694)
      at hudson.maven.MavenModuleSetBuild$Builder.call(MavenModuleSetBuild.java:638)
      at hudson.remoting.UserRequest.perform(UserRequest.java:114)
      at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      at hudson.remoting.Request$2.run(Request.java:270)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: org.apache.maven.plugin.MojoExecutionException: A java source file could not be added
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at org.codehaus.groovy.runtime.MetaClassHelper.doConstructorInvoke(MetaClassHelper.java:535)
      at groovy.lang.MetaClassImpl.doConstructorInvoke(MetaClassImpl.java:2356)
      at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1255)
      at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1185)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeConstructorOf(InvokerHelper.java:809)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNewN(ScriptBytecodeAdapter.java:230)
      at org.codehaus.mojo.findbugs.FindBugsMojo.fail(FindBugsMojo.groovy:1187)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:78)
      at org.codehaus.mojo.findbugs.FindBugsMojo.executeReport(FindBugsMojo.groovy:771)
      at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:101)
      at sun.reflect.GeneratedMethodAccessor72.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at hudson.maven.agent.ComponentInterceptor.invoke(ComponentInterceptor.java:47)
      at hudson.maven.agent.PluginManagerInterceptor$3.invoke(PluginManagerInterceptor.java:229)
      ... 37 more
      Caused by: java.io.IOException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
      at edu.umd.cs.findbugs.filter.Filter.<init>(Filter.java:128)
      at edu.umd.cs.findbugs.FindBugs.configureFilter(FindBugs.java:389)
      at edu.umd.cs.findbugs.FindBugs2.addFilter(FindBugs2.java:314)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756)
      at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:778)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:758)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:170)
      at org.codehaus.mojo.findbugs.FindBugsMojo.addFiltersToFindBugs(FindBugsMojo.groovy:564)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:78)
      at org.codehaus.mojo.findbugs.FindBugsMojo.initialiseFindBugs(FindBugsMojo.groovy:1063)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:78)
      at org.codehaus.mojo.findbugs.FindBugsMojo.executeReport(FindBugsMojo.groovy:767)
      ... 43 more
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 5 minutes 11 seconds
      [INFO] Finished at: Tue Oct 26 22:13:35 UTC 2010
      [INFO] Final Memory: 120M/254M
      [INFO] ------------------------------------------------------------------------

        Attachments

          Issue Links

            Activity

            Hide
            teilo James Nord added a comment -

            most likely caused by Hudson-7312

            Show
            teilo James Nord added a comment - most likely caused by Hudson-7312
            Hide
            drulli Ulli Hafner added a comment -

            Integrated in Hudson Plug-ins (Compile) #69
            JENKINS-7932 Don't change property to NULL.
            JENKINS-7932 Reset SAX parser property after all files have been parsed.

            Show
            drulli Ulli Hafner added a comment - Integrated in Hudson Plug-ins (Compile) #69 JENKINS-7932 Don't change property to NULL. JENKINS-7932 Reset SAX parser property after all files have been parsed.
            Hide
            teilo James Nord added a comment -

            this didn't actually fix it

            Show
            teilo James Nord added a comment - this didn't actually fix it
            Hide
            drulli Ulli Hafner added a comment -

            I.e., release 4.15 is not working for you?

            Show
            drulli Ulli Hafner added a comment - I.e., release 4.15 is not working for you?
            Hide
            drulli Ulli Hafner added a comment -

            Does exception also occur if you disable the processing with the findbugs plug-in? (I.e. run only findbugs m2 plugin?) I think the problem is in the findbugs core library...

            Show
            drulli Ulli Hafner added a comment - Does exception also occur if you disable the processing with the findbugs plug-in? (I.e. run only findbugs m2 plugin?) I think the problem is in the findbugs core library...
            Hide
            teilo James Nord added a comment - - edited

            4.15 is also broken.
            The builds used to all work before we upgraded hudson and all it's plugins - and they work from the command line.

            our commit builds mvn deploy checkstyle:checkstyle pmd:pmd findbugs:findbugs work ok
            our nightly builds
            mvn deploy site-deploy are the ones that fail.

            In our case no alternate parser has been set so I think the following code is wrong (as it does not unset the parser) - in our case oldProperty would be null
            NB shouldn't this

            findbugs/plugin/src/main/java/hudson/plugins/findbugs/parser/FindBugsParser.java
            {{
            private SortedBugCollection readXml(final InputStream file) throws IOException, DocumentException {
            String oldProperty = System.getProperty(SAX_DRIVER_PROPERTY);
            System.setProperty(SAX_DRIVER_PROPERTY, SAXParser.class.getName());
            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(FindBugsParser.class.getClassLoader());
            SortedBugCollection collection = new SortedBugCollection();
            collection.readXML(file);
            Thread.currentThread().setContextClassLoader(contextClassLoader);
            if (oldProperty != null)

            { System.setProperty(SAX_DRIVER_PROPERTY, oldProperty); }

            }
            }}
            be
            {{
            private SortedBugCollection readXml(final InputStream file) throws IOException, DocumentException

            { String oldProperty = System.getProperty(SAX_DRIVER_PROPERTY); System.setProperty(SAX_DRIVER_PROPERTY, SAXParser.class.getName()); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(FindBugsParser.class.getClassLoader()); SortedBugCollection collection = new SortedBugCollection(); collection.readXML(file); Thread.currentThread().setContextClassLoader(contextClassLoader); System.setProperty(SAX_DRIVER_PROPERTY, oldProperty); }

            }}
            But more intersetingly Findbugs requires J2SE 5 or above and so should really be using the stock JDK parser and so this shouldn't need to be set - or should be set to the stock JDK parser which is ...
            So in reality I would say that JENKINS-7312 should be fixed in the actual project setup not findbugs.

            However the (SUN/Oracle) JDK implementation explicitly handles null for the property and then will fallback to the stock parser (which in Oracle JDK6 is "com.sun.org.apache.xerces.internal.parsers.SAXParser")

            Show
            teilo James Nord added a comment - - edited 4.15 is also broken. The builds used to all work before we upgraded hudson and all it's plugins - and they work from the command line. our commit builds mvn deploy checkstyle:checkstyle pmd:pmd findbugs:findbugs work ok our nightly builds mvn deploy site-deploy are the ones that fail. In our case no alternate parser has been set so I think the following code is wrong (as it does not unset the parser) - in our case oldProperty would be null NB shouldn't this findbugs/plugin/src/main/java/hudson/plugins/findbugs/parser/FindBugsParser.java {{ private SortedBugCollection readXml(final InputStream file) throws IOException, DocumentException { String oldProperty = System.getProperty(SAX_DRIVER_PROPERTY); System.setProperty(SAX_DRIVER_PROPERTY, SAXParser.class.getName()); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(FindBugsParser.class.getClassLoader()); SortedBugCollection collection = new SortedBugCollection(); collection.readXML(file); Thread.currentThread().setContextClassLoader(contextClassLoader); if (oldProperty != null) { System.setProperty(SAX_DRIVER_PROPERTY, oldProperty); } } }} be {{ private SortedBugCollection readXml(final InputStream file) throws IOException, DocumentException { String oldProperty = System.getProperty(SAX_DRIVER_PROPERTY); System.setProperty(SAX_DRIVER_PROPERTY, SAXParser.class.getName()); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(FindBugsParser.class.getClassLoader()); SortedBugCollection collection = new SortedBugCollection(); collection.readXML(file); Thread.currentThread().setContextClassLoader(contextClassLoader); System.setProperty(SAX_DRIVER_PROPERTY, oldProperty); } }} But more intersetingly Findbugs requires J2SE 5 or above and so should really be using the stock JDK parser and so this shouldn't need to be set - or should be set to the stock JDK parser which is ... So in reality I would say that JENKINS-7312 should be fixed in the actual project setup not findbugs. However the (SUN/Oracle) JDK implementation explicitly handles null for the property and then will fallback to the stock parser (which in Oracle JDK6 is "com.sun.org.apache.xerces.internal.parsers.SAXParser")
            Hide
            drulli Ulli Hafner added a comment -

            I see. The code is wrong if there is no property set I think that both issues are fixed if I change the property to Xerces if the property is set and don't change it at all if it is null. (This is easier than waiting for a change in the maven plugin that caused JENKINS-7312).

            BTW: you can use the {code} macro to make your comment more readable

            Show
            drulli Ulli Hafner added a comment - I see. The code is wrong if there is no property set I think that both issues are fixed if I change the property to Xerces if the property is set and don't change it at all if it is null. (This is easier than waiting for a change in the maven plugin that caused JENKINS-7312 ). BTW: you can use the {code} macro to make your comment more readable
            Hide
            teilo James Nord added a comment -

            SOunds ok to me.
            Sorry for the spam - I knew there was a way somewhere to mark things as code

            Show
            teilo James Nord added a comment - SOunds ok to me. Sorry for the spam - I knew there was a way somewhere to mark things as code

              People

              • Assignee:
                drulli Ulli Hafner
                Reporter:
                teilo James Nord
              • Votes:
                1 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: