• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • violations-plugin
    • None
    • Debian Lenny, Java 1.6.20, Violations 0.7.7, Grails 1.3.5, CodeNarc plugin 0.7 (CodeNarc 0.10)

      I've followed the steps on http://leanjavaengineering.wordpress.com/2010/08/25/grails-codenarc-hudson/ and I'm getting an ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception
      java.lang.NullPointerException.

      Console Output

      View as plain text
      Started by user anonymous
      [workspace] $ grails clean
      Welcome to Grails 1.3.5 - http://grails.org/
      Licensed under Apache Standard License 2.0
      Grails home is set to: /opt/install/grails

      Base Directory: /home/tek/.hudson/jobs/myapp/workspace
      Resolving dependencies...
      Dependencies resolved in 4923ms.
      Running script /opt/install/grails/scripts/Clean.groovy
      Environment set to development
      [delete] Deleting: /home/tek/.grails/1.3.5/projects/workspace/resources/web.xml
      [delete] Deleting directory /home/tek/.hudson/jobs/myapp/workspace/target/classes
      [delete] Deleting directory /home/tek/.grails/1.3.5/projects/workspace/plugin-classes
      [delete] Deleting directory /home/tek/.grails/1.3.5/projects/workspace/resources
      [delete] Deleting directory /home/tek/.hudson/jobs/myapp/workspace/target/test-classes
      [workspace] $ grails test-app
      Welcome to Grails 1.3.5 - http://grails.org/
      Licensed under Apache Standard License 2.0
      Grails home is set to: /opt/install/grails

      Base Directory: /home/tek/.hudson/jobs/myapp/workspace
      Resolving dependencies...
      Dependencies resolved in 5055ms.
      Running script /opt/install/grails/scripts/TestApp.groovy
      Environment set to test
      [mkdir] Created dir: /home/tek/.grails/1.3.5/projects/workspace/plugin-classes
      [groovyc] Compiling 32 source files to /home/tek/.grails/1.3.5/projects/workspace/plugin-classes
      Note: Some input files use unchecked or unsafe operations.
      Note: Recompile with -Xlint:unchecked for details.
      [mkdir] Created dir: /home/tek/.hudson/jobs/myapp/workspace/target/classes
      [groovyc] Compiling 8 source files to /home/tek/.hudson/jobs/myapp/workspace/target/classes
      [copy] Copied 4 empty directories to 2 empty directories under /home/tek/.grails/1.3.5/projects/workspace/resources
      [copy] Copied 7 empty directories to 6 empty directories under /home/tek/.grails/1.3.5/projects/workspace/resources
      [copy] Copied 2 empty directories to 2 empty directories under /home/tek/.grails/1.3.5/projects/workspace/resources
      [copy] Copied 2 empty directories to 2 empty directories under /home/tek/.grails/1.3.5/projects/workspace/resources
      [mkdir] Created dir: /home/tek/.hudson/jobs/myapp/workspace/target/test-reports/html
      [mkdir] Created dir: /home/tek/.hudson/jobs/myapp/workspace/target/test-reports/plain

      Starting unit test phase ...
      [mkdir] Created dir: /home/tek/.hudson/jobs/myapp/workspace/target/test-classes/unit

      Starting integration test phase ...
      [copy] Copying 1 file to /home/tek/.hudson/jobs/myapp/workspace/target/test-classes/integration
      [copy] Copying 1 file to /home/tek/.hudson/jobs/myapp/workspace/target/test-classes
      [mkdir] Created dir: /home/tek/.grails/1.3.5/projects/workspace/resources/grails-app/i18n
      [native2ascii] Converting 13 files from /home/tek/.hudson/jobs/myapp/workspace/grails-app/i18n to /home/tek/.grails/1.3.5/projects/workspace/resources/grails-app/i18n
      [mkdir] Created dir: /home/tek/.grails/1.3.5/projects/workspace/resources/plugins/code-coverage-1.1.8/grails-app/i18n
      [native2ascii] Converting 1 file from /home/tek/.grails/1.3.5/projects/workspace/plugins/code-coverage-1.1.8/grails-app/i18n to /home/tek/.grails/1.3.5/projects/workspace/resources/plugins/code-coverage-1.1.8/grails-app/i18n
      [mkdir] Created dir: /home/tek/.grails/1.3.5/projects/workspace/resources/plugins/codenarc-0.7/grails-app/i18n
      [native2ascii] Converting 1 file from /home/tek/.grails/1.3.5/projects/workspace/plugins/codenarc-0.7/grails-app/i18n to /home/tek/.grails/1.3.5/projects/workspace/resources/plugins/codenarc-0.7/grails-app/i18n
      [copy] Copying 1 file to /home/tek/.hudson/jobs/myapp/workspace/target/classes

      Starting other test phase ...
      [junitreport] Processing /home/tek/.hudson/jobs/myapp/workspace/target/test-reports/TESTS-TestSuites.xml to /tmp/null1784349293
      [junitreport] Loading stylesheet /opt/install/grails/lib/junit-frames.xsl
      [junitreport] Transform time: 5212ms
      [junitreport] Deleting: /tmp/null1784349293

      Tests PASSED - view reports in target/test-reports
      Application context shutting down...
      Application context shutdown.
      [workspace] $ grails codenarc
      Welcome to Grails 1.3.5 - http://grails.org/
      Licensed under Apache Standard License 2.0
      Grails home is set to: /opt/install/grails

      Base Directory: /home/tek/.hudson/jobs/myapp/workspace
      Resolving dependencies...
      Dependencies resolved in 6465ms.
      Running script /home/tek/.grails/1.3.5/projects/workspace/plugins/codenarc-0.7/scripts/Codenarc.groovy
      Environment set to development
      Running CodeNarc ...
      CodeNarc completed: (p1=0; p2=1; p3=58) 8666ms
      CodeNarc finished; report generated: target/test-reports/CodeNarcReport.xml
      ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception
      java.lang.NullPointerException
      at hudson.plugins.violations.generate.OutputFileModel.doViolation(OutputFileModel.java:198)
      at hudson.plugins.violations.generate.OutputFileModel.createLimited(OutputFileModel.java:113)
      at hudson.plugins.violations.generate.OutputFileModel.execute(OutputFileModel.java:80)
      at hudson.plugins.violations.generate.ExecuteFilePath.execute(ExecuteFilePath.java:45)
      at hudson.plugins.violations.generate.GenerateXML.execute(GenerateXML.java:47)
      at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:124)
      at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:27)
      at hudson.FilePath.act(FilePath.java:753)
      at hudson.FilePath.act(FilePath.java:735)
      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:601)
      at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:580)
      at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:558)
      at hudson.model.Build$RunnerImpl.post2(Build.java:157)
      at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:528)
      at hudson.model.Run.run(Run.java:1303)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:137)
      Finished: FAILURE

        1. CodeNarcReport.html
          31 kB
        2. CodeNarcReport.xml
          17 kB
        3. Config.groovy
          4 kB
        4. config.xml
          6 kB

          [JENKINS-7902] Violations plugin raises a NPE using Codenarc

          rbramley added a comment -

          Is there any more stack trace available?
          Please can you attach the actual XML report file rather than the HTML report.

          Have you tried setting the faux project path?

          rbramley added a comment - Is there any more stack trace available? Please can you attach the actual XML report file rather than the HTML report. Have you tried setting the faux project path?

          ricardoyepex added a comment - - edited

          About the stacktrace, I'm copying all that I see on http://localhost:8080/hudson/job/myapp/8/console. There is a file with more information?

          I've not set the Faux Project Path because my grails project files are directly on ~/.hudson/jobs/myapp/workspace, not I've no other folder like "trunk" or something like that.

          Thank you very much.

          ricardoyepex added a comment - - edited About the stacktrace, I'm copying all that I see on http://localhost:8080/hudson/job/myapp/8/console . There is a file with more information? I've not set the Faux Project Path because my grails project files are directly on ~/.hudson/jobs/myapp/workspace, not I've no other folder like "trunk" or something like that. Thank you very much.

          rbramley added a comment -

          Have managed to reproduce this locally - so can start investigating.

          rbramley added a comment - Have managed to reproduce this locally - so can start investigating.

          ricardoyepex added a comment -

          Great! Thanks a lot.

          ricardoyepex added a comment - Great! Thanks a lot.

          rbramley added a comment - - edited

          Have finally managed to get some time to look into this.

          The change checked in for JENKINS-7271 broke the code - it looks as though the codenarc.source.patch was only partially applied.

          The original code set source then message, as of Subversion revision 36264 it no longer set the message on the violation object:

                  ret.setSource(getString("ruleName"));
                  setSeverity(ret, getString("priority"));
                  getParser().next();
          
          
                  // get the contents of the embedded SourceLine or Message element
                  try {
                      expectNextTag("SourceLine");
                  } catch (IOException ioe) {
                      expectNextTag("Message");
                  }
                  ret.setSource(getNextText("Missing SourceLine or Message"));
          

          As message was null, it caused a null pointer exception on this piece of OutputFileModel:

                  printAttr("message", v.getMessage().trim());
                  printAttr("severity-level", v.getSeverityLevel());
                  if (v.getPopupMessage() != null) {
                      printAttr("popup-message", v.getPopupMessage().trim());
                  }
          

          Just stumbled across Jira JENKINS-8046 which duplicates this issue and contains a link to this GitHub commit:

          https://github.com/hudson/hudson-plugins/commit/ec5b03d72a8bcf510960867707fab625e9b807e8

          - fixed NPE. It's not clear if the Violation class is supposed to have null message or not, but it doesn't hurt to be defensive.
          - added a test case that reproduces NPE on message.
          - Codenarc parser shouldn't override the 'source' information by a pointless copy of the source code.
          
          git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/plugins@36380 71c3de6d-444a-0410-be80-ed276b4c234a
          
          kohsuke (author)
          October 29, 2010
          

          rbramley added a comment - - edited Have finally managed to get some time to look into this. The change checked in for JENKINS-7271 broke the code - it looks as though the codenarc.source.patch was only partially applied. The original code set source then message, as of Subversion revision 36264 it no longer set the message on the violation object: ret.setSource(getString("ruleName")); setSeverity(ret, getString("priority")); getParser().next(); // get the contents of the embedded SourceLine or Message element try { expectNextTag("SourceLine"); } catch (IOException ioe) { expectNextTag("Message"); } ret.setSource(getNextText("Missing SourceLine or Message")); As message was null, it caused a null pointer exception on this piece of OutputFileModel: printAttr("message", v.getMessage().trim()); printAttr("severity-level", v.getSeverityLevel()); if (v.getPopupMessage() != null) { printAttr("popup-message", v.getPopupMessage().trim()); } Just stumbled across Jira JENKINS-8046 which duplicates this issue and contains a link to this GitHub commit: https://github.com/hudson/hudson-plugins/commit/ec5b03d72a8bcf510960867707fab625e9b807e8 - fixed NPE. It's not clear if the Violation class is supposed to have null message or not, but it doesn't hurt to be defensive. - added a test case that reproduces NPE on message. - Codenarc parser shouldn't override the 'source' information by a pointless copy of the source code. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/plugins@36380 71c3de6d-444a-0410-be80-ed276b4c234a kohsuke (author) October 29, 2010

          bocytko added a comment -

          The stacktrace in JENKINS-8046 is different ("hudson.plugins.violations.parse.AbstractTypeParser.parse(AbstractTypeParser.java:64)" there vs. "hudson.plugins.violations.generate.OutputFileModel.doViolation(OutputFileModel.java:198)" here).

          I've set up a job for a basic Groovy project and I get the same error as reported. Stacktrace below.

          My configuration:
          OS: Linux ubuntu 2.6.35-22-generic #33-Ubuntu SMP Sun Sep 19 20:34:50 UTC 2010 i686 GNU/Linux
          Jenkins: 1.405 (1.401 produced the same error)
          Jenkins Violations Plugin: 0.7.7

          Servlet container: apache-tomcat-7.0.11
          JRE: OpenJDK Runtime Environment (IcedTea6 1.9.5) (6b20-1.9.5-0ubuntu1)
          Groovy Version: 1.7.10 JVM: 1.6.0_20
          CodeNarc: 0.13

          [TASKS] Scanning workspace files for tasks...
          ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception
          java.lang.NullPointerException
          	at hudson.plugins.violations.generate.OutputFileModel.doViolation(OutputFileModel.java:198)
          	at hudson.plugins.violations.generate.OutputFileModel.createLimited(OutputFileModel.java:113)
          	at hudson.plugins.violations.generate.OutputFileModel.execute(OutputFileModel.java:80)
          	at hudson.plugins.violations.generate.ExecuteFilePath.execute(ExecuteFilePath.java:45)
          	at hudson.plugins.violations.generate.GenerateXML.execute(GenerateXML.java:47)
          	at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:124)
          	at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:27)
          	at hudson.FilePath.act(FilePath.java:757)
          	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:649)
          	at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:625)
          	at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:603)
          	at hudson.model.Build$RunnerImpl.post2(Build.java:161)
          	at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:572)
          	at hudson.model.Run.run(Run.java:1386)
          	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          	at hudson.model.ResourceController.execute(ResourceController.java:88)
          	at hudson.model.Executor.run(Executor.java:145)
          Finished: FAILURE
          

          bocytko added a comment - The stacktrace in JENKINS-8046 is different ("hudson.plugins.violations.parse.AbstractTypeParser.parse(AbstractTypeParser.java:64)" there vs. "hudson.plugins.violations.generate.OutputFileModel.doViolation(OutputFileModel.java:198)" here). I've set up a job for a basic Groovy project and I get the same error as reported. Stacktrace below. My configuration: OS: Linux ubuntu 2.6.35-22-generic #33-Ubuntu SMP Sun Sep 19 20:34:50 UTC 2010 i686 GNU/Linux Jenkins: 1.405 (1.401 produced the same error) Jenkins Violations Plugin: 0.7.7 Servlet container: apache-tomcat-7.0.11 JRE: OpenJDK Runtime Environment (IcedTea6 1.9.5) (6b20-1.9.5-0ubuntu1) Groovy Version: 1.7.10 JVM: 1.6.0_20 CodeNarc: 0.13 [TASKS] Scanning workspace files for tasks... ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception java.lang.NullPointerException at hudson.plugins.violations.generate.OutputFileModel.doViolation(OutputFileModel.java:198) at hudson.plugins.violations.generate.OutputFileModel.createLimited(OutputFileModel.java:113) at hudson.plugins.violations.generate.OutputFileModel.execute(OutputFileModel.java:80) at hudson.plugins.violations.generate.ExecuteFilePath.execute(ExecuteFilePath.java:45) at hudson.plugins.violations.generate.GenerateXML.execute(GenerateXML.java:47) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:124) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:27) at hudson.FilePath.act(FilePath.java:757) 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:649) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:625) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:603) at hudson.model.Build$RunnerImpl.post2(Build.java:161) at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:572) at hudson.model.Run.run(Run.java:1386) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:145) Finished: FAILURE

          bocytko added a comment -

          This issue has been fixed with JENKINS-8046. I verified this on Jenkins 1.405-1.407 by building violations plugin's trunk manually (v 0.7.8).

          bocytko added a comment - This issue has been fixed with JENKINS-8046 . I verified this on Jenkins 1.405-1.407 by building violations plugin's trunk manually (v 0.7.8).

            rbramley rbramley
            ricardoyepex ricardoyepex
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: