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

Violations report failed to due to encoding exception.

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • violations-plugin
    • None
    • - Windows 2008 Server R2 (Master) 64-bit Java
      - Windows 2008 Server R2 (Slave) 32-bit Java
      - Tomcat 7.0.6
      - Oracle Java JDK 6.0-update 24
      - Jenkins 1.399
      - Volations plugin 0.7.7

      Builds are failing due to the fact Violations plugin is turned on. It complains about encoding with SAX exception not understanding the Cp1252 encoding. Any help or solution to this problem is appreciated.

      ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception
      hudson.util.IOException2: remote file operation failed: C:\hudson\workspace\adhoc-6.1 at hudson.remoting.Channel@1c344a47:GAQACCPACERP04
      at hudson.FilePath.act(FilePath.java:753)
      at hudson.FilePath.act(FilePath.java:739)
      at hudson.plugins.violations.ViolationsPublisher.perform(ViolationsPublisher.java:74)
      at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
      at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:644)
      at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:623)
      at hudson.ivy.IvyModuleSetBuild$RunnerImpl.post2(IvyModuleSetBuild.java:587)
      at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:570)
      at hudson.model.Run.run(Run.java:1386)
      at hudson.ivy.IvyModuleSetBuild.run(IvyModuleSetBuild.java:282)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:145)
      Caused by: hudson.util.IOException2: Cannot parse module\target\reports\pmd\cpd\main-cpd.xml
      at hudson.plugins.violations.parse.ViolationsDOMParser.parse(ViolationsDOMParser.java:69)
      at hudson.plugins.violations.ViolationsCollector.doType(ViolationsCollector.java:189)
      at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:116)
      at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:27)
      at hudson.FilePath$FileCallableWrapper.call(FilePath.java:1940)
      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 hudson.remoting.Engine$1$1.run(Engine.java:59)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: org.xml.sax.SAXParseException: Invalid encoding name "Cp1252".
      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:208)
      at hudson.plugins.violations.parse.ViolationsDOMParser.parse(ViolationsDOMParser.java:58)
      ... 14 more
      Finished: FAILURE

          [JENKINS-9010] Violations report failed to due to encoding exception.

          Anders H. Abrahamsen added a comment - - edited

          We've recently run into the same issue on our Jenkins server. If we try to run "Report Violations" it will crash on the cpd file (which is in fact in Cp1252). If we remove the XML pattern for the CPD file it works (as the PMD file is in UTF-8). The strange thing is that it just started happening on all projects last thursday (and we've run some of these projects without any configuration change for over a year).

          We get the excact same stacktrace btw.

          Anders H. Abrahamsen added a comment - - edited We've recently run into the same issue on our Jenkins server. If we try to run "Report Violations" it will crash on the cpd file (which is in fact in Cp1252). If we remove the XML pattern for the CPD file it works (as the PMD file is in UTF-8). The strange thing is that it just started happening on all projects last thursday (and we've run some of these projects without any configuration change for over a year). We get the excact same stacktrace btw.

          I went back into a project with the same properties which have not been built last week and checked the encoding on the cpd.xml file. It is windows-1252, not Cp1252 and this might be why Xerces is having difficulties. windows-1252 is the IANA standard, while Cp1252 is not. I will check why the xml encoding has changed.

          Anders H. Abrahamsen added a comment - I went back into a project with the same properties which have not been built last week and checked the encoding on the cpd.xml file. It is windows-1252, not Cp1252 and this might be why Xerces is having difficulties. windows-1252 is the IANA standard, while Cp1252 is not. I will check why the xml encoding has changed.

          For xml files, one needs to set the encoding correctly, otherwise the encoding defaults
          to utf-8.
          for windows cp1252, set the the xml wart to:
          <?xml version="1.0" encoding="windows-1252"?>
          but the best plan is to always use utf-8.
          this can however also cause problems, since widows programs inclined to add a byte order marker
          (bom) which is not needed by utf-8 but should be benign and is used to mark utf-8 files as non
          cp1252 files. This causes problems with
          java reader i/o classes which think the the bom character is invalid. The xml parsers
          do not have this problem.

          peterkittreilly added a comment - For xml files, one needs to set the encoding correctly, otherwise the encoding defaults to utf-8. for windows cp1252, set the the xml wart to: <?xml version="1.0" encoding="windows-1252"?> but the best plan is to always use utf-8. this can however also cause problems, since widows programs inclined to add a byte order marker (bom) which is not needed by utf-8 but should be benign and is used to mark utf-8 files as non cp1252 files. This causes problems with java reader i/o classes which think the the bom character is invalid. The xml parsers do not have this problem.

          I'm using my own ant scripts and solved it this way:

          <replace file="${reports.cpd}/cpd.xml" token="<?xml version="1.0" encoding="Cp1252"?>" value="<?xml version="1.0" encoding="windows-1252"?>" />

          Daniel Hirscher added a comment - I'm using my own ant scripts and solved it this way: <replace file="${reports.cpd}/cpd.xml" token="<?xml version="1.0" encoding="Cp1252"?>" value="<?xml version="1.0" encoding="windows-1252"?>" />

          Mark Waite added a comment -

          The violations plugin is deprecated. It has an unresolved security vulnerability. The last commit to the source code repository was over 7 years ago. Closing the issue as "Won't fix"

          Mark Waite added a comment - The violations plugin is deprecated. It has an unresolved security vulnerability. The last commit to the source code repository was over 7 years ago. Closing the issue as "Won't fix"

            peterkittreilly peterkittreilly
            kevinksw Kevin Wong
            Votes:
            5 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: