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

Sporadic IOException: Failed to persist config

      When creating the projects, I am getting sporadic failures in the jenkins error log as seen below. Jobs then fail to be updated.

      INFO: createOrUpdateConfig for WebContent
      Mar 23, 2015 10:29:12 AM javaposse.jobdsl.plugin.JenkinsJobManagement updateExistingItem
      WARNING: Error writing updated item to file.
      java.io.IOException: Failed to persist config.xml
      	at hudson.model.AbstractItem.updateByXml(AbstractItem.java:646)
      	at javaposse.jobdsl.plugin.JenkinsJobManagement.updateExistingItem(JenkinsJobManagement.java:378)
      	at javaposse.jobdsl.plugin.JenkinsJobManagement.createOrUpdateConfig(JenkinsJobManagement.java:123)
      	at javaposse.jobdsl.dsl.DslScriptLoader.extractGeneratedJobs(DslScriptLoader.java:120)
      	at javaposse.jobdsl.dsl.DslScriptLoader.runDslEngine(DslScriptLoader.java:97)
      	at javaposse.jobdsl.plugin.ExecuteDslScripts.perform(ExecuteDslScripts.java:203)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:761)
      	at hudson.model.Build$BuildExecution.build(Build.java:203)
      	at hudson.model.Build$BuildExecution.doRun(Build.java:160)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:536)
      	at hudson.model.Run.execute(Run.java:1751)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:89)
      	at hudson.model.Executor.run(Executor.java:240)
      Caused by: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
      java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
      	at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:230)
      	at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:191)
      	at jenkins.util.xml.XMLUtils.safeTransform(XMLUtils.java:48)
      	at hudson.model.AbstractItem.updateByXml(AbstractItem.java:641)
      	... 14 more
      Caused by: java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:430)
      	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:383)
      	at org.xml.sax.helpers.NewInstance.newInstance(NewInstance.java:82)
      	at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:228)
      	... 17 more
      

        1. support_2016-07-01_13.06.55.zip
          1.06 MB
        2. support_KO.zip
          18 kB
        3. support_OK.zip
          18 kB
        4. support.zip
          29 kB

          [JENKINS-27548] Sporadic IOException: Failed to persist config

          Michael Longo added a comment - - edited

          Had the same issue today with jenkins 2.107.1 while trying to POST a config.xml

          java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
          	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
          	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:560)
          	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          	at org.xml.sax.helpers.NewInstance.newInstance(NewInstance.java:82)
          	at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:228)
          Caused: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
          java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
          	at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:230)
          	at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:191)
          	at jenkins.util.xml.XMLUtils.safeTransform(XMLUtils.java:69)
          	at hudson.model.AbstractItem.updateByXml(AbstractItem.java:748)
          Caused: java.io.IOException: Failed to persist config.xml
          	at hudson.model.AbstractItem.updateByXml(AbstractItem.java:751)
          	at hudson.model.AbstractItem.doConfigDotXml(AbstractItem.java:691)
          	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
          	at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343)
          	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184)
          	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:117)
          
          

          Clearing the property did not help. "Fixed" it the hard way, by executing the following code into the script console:

          URL url = new URL("http://central.maven.org/maven2/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar");
          
          URLClassLoader classLoader = (URLClassLoader)ClassLoader.getSystemClassLoader();
          java.lang.reflect.Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
          method.setAccessible(true);
          method.invoke(classLoader, url);
          
          System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser");

          CLEARLY NOT a good fix, but a fix never the less if anyone is blocked by this issue. Of course if you reboot jenkins the fix is gone.

          Funny thing is that the ClassLoader where the script console is executing did already have the SAXParser class (Class.forName("..") worked) but the default classLoaded did not (Class.forName("..", false, ClassLoader.getSystemClassLoader()) => null)

           

          Michael Longo added a comment - - edited Had the same issue today with jenkins 2.107.1 while trying to POST a config.xml java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang. ClassLoader .loadClass( ClassLoader .java:424) at java.lang. ClassLoader .loadClass( ClassLoader .java:357) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:560) at java.lang. ClassLoader .loadClass( ClassLoader .java:357) at org.xml.sax.helpers.NewInstance.newInstance(NewInstance.java:82) at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:228) Caused: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:230) at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:191) at jenkins.util.xml.XMLUtils.safeTransform(XMLUtils.java:69) at hudson.model.AbstractItem.updateByXml(AbstractItem.java:748) Caused: java.io.IOException: Failed to persist config.xml at hudson.model.AbstractItem.updateByXml(AbstractItem.java:751) at hudson.model.AbstractItem.doConfigDotXml(AbstractItem.java:691) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:117) Clearing the property did not help. "Fixed" it the hard way, by executing the following code into the script console: URL url = new URL( "http: //central.maven.org/maven2/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar" ); URLClassLoader classLoader = (URLClassLoader) ClassLoader .getSystemClassLoader(); java.lang.reflect.Method method = URLClassLoader. class. getDeclaredMethod( "addURL" , URL.class); method.setAccessible( true ); method.invoke(classLoader, url); System .setProperty( "org.xml.sax.driver" , "org.apache.xerces.parsers.SAXParser" ); CLEARLY NOT a good fix, but a fix never the less if anyone is blocked by this issue. Of course if you reboot jenkins the fix is gone. Funny thing is that the ClassLoader where the script console is executing did already have the SAXParser class (Class.forName("..") worked) but the default classLoaded did not (Class.forName("..", false, ClassLoader.getSystemClassLoader()) => null)  

          Ulli Hafner added a comment -

          The warnings-ng plugin uses a different library now (it replaces analysis-core). It would be great if you can check the beta if it resolves your problem.

          Ulli Hafner added a comment - The warnings-ng plugin uses a different library now (it replaces analysis-core). It would be great if you can check the beta if it resolves your problem.

          tiller: thanks for the "hard" fix. We were blocked for a while there.

          drulli: FYI: aside from the analysis-core, we only have the find-bugs-plugin@4.72 installed.

          $ grep -ir 'org.apache.xerces.parsers.SAXParser' *
          Binary file analysis-core/WEB-INF/lib/xercesImpl-2.11.0.jar matches
          Binary file findbugs/WEB-INF/lib/library-2.0.4.jar matches
          

          Steve Boardwell added a comment - tiller : thanks for the "hard" fix. We were blocked for a while there. drulli : FYI: aside from the analysis-core, we only have the find-bugs-plugin@4.72 installed. $ grep -ir 'org.apache.xerces.parsers.SAXParser' * Binary file analysis-core/WEB-INF/lib/xercesImpl-2.11.0.jar matches Binary file findbugs/WEB-INF/lib/library-2.0.4.jar matches

          Ulli Hafner added a comment -

          Analysis-core and warnings plugin are deprecated and will be replaced by warnings-ng.

          Ulli Hafner added a comment - Analysis-core and warnings plugin are deprecated and will be replaced by warnings-ng.

          Michael Longo added a comment -

          drulli : stupid question, are analysis-core and warnings plugins visible in the plugin list in Jenkins UI? Because I don't have any of these plugins in my jenkins and I still had the issue. So is it related?

          Michael Longo added a comment - drulli : stupid question, are analysis-core and warnings plugins visible in the plugin list in Jenkins UI? Because I don't have any of these plugins in my jenkins and I still had the issue. So is it related?

          Ulli Hafner added a comment -

          Yes these plugins are visible (static analysis utilities plugin and warning plugin). It is still not clear which plugins are actually causing the bug, so yes you can be affected even if you do not have these plugins installed.

          Ulli Hafner added a comment - Yes these plugins are visible (static analysis utilities plugin and warning plugin). It is still not clear which plugins are actually causing the bug, so yes you can be affected even if you do not have these plugins installed.

          Ulli Hafner added a comment -

          And an additional note: the problem is not that the sax parser is a dependency of a plugin, somehow some plugin sets the property and should not do it.

          Ulli Hafner added a comment - And an additional note: the problem is not that the sax parser is a dependency of a plugin, somehow some plugin sets the property and should not do it.

          Ulli Hafner added a comment -

          In the new beta of the warnings-ng plugin a warning is now logged if your system has a non empty sax parser property. Can you please check the log output on your system if there is such a warning?

          Ulli Hafner added a comment - In the new beta of the warnings-ng plugin a warning is now logged if your system has a non empty sax parser property. Can you please check the log output on your system if there is such a warning?

          Where do I have do search for this warning? I don't see anyone in the build console log output. Does this means the property is correct?

          Struggeling on the problem since our jenkins was updated by the admins to 2.138

           

          Do I understand the other commenty correctly that removing all of the analysis plugins and only use warning-ng should fix that?

          Bukama Marenellin added a comment - Where do I have do search for this warning? I don't see anyone in the build console log output. Does this means the property is correct? Struggeling on the problem since our jenkins was updated by the admins to 2.138   Do I understand the other commenty correctly that removing all of the analysis plugins and only use warning-ng should fix that?

          Ulli Hafner added a comment -

          The plugin is deprecated and not maintained anymore. Please upgrade to the warnings-ng plugin.

          Ulli Hafner added a comment - The plugin is deprecated and not maintained anymore. Please upgrade to the warnings-ng plugin.

            Unassigned Unassigned
            andrewk Andrew Kujtan
            Votes:
            10 Vote for this issue
            Watchers:
            24 Start watching this issue

              Created:
              Updated:
              Resolved: