Sonar PMD Plugin – Running in JDK 1.4 mode

If you are analyzing your project using sonar-runner (version 1.0) you might see the below exception

[ERROR]  Fail to execute PMD. Following file is ignored: <path-to-java-file>
net.sourceforge.pmd.ast.ParseException: Can't use static imports when running in JDK 1.4 mode!
        at net.sourceforge.pmd.ast.JavaParser.checkForBadStaticImportUsage(JavaParser.java:26) [pmd-4.2.5.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ImportDeclaration(JavaParser.java:248) [pmd-4.2.5.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.CompilationUnit(JavaParser.java:124) [pmd-4.2.5.jar:na]
        at net.sourceforge.pmd.parsers.Java14Parser.parse(Java14Parser.java:23) [pmd-4.2.5.jar:na]
        at net.sourceforge.pmd.PMD.processFile(PMD.java:98) [pmd-4.2.5.jar:na]
        at net.sourceforge.pmd.PMD.processFile(PMD.java:75) [pmd-4.2.5.jar:na]
        at org.sonar.plugins.pmd.PmdExecutor.execute(PmdExecutor.java:70) [sonar-pmd-plugin-2.8.jar:na]
        at org.sonar.plugins.pmd.PmdSensor.analyse(PmdSensor.java:45) [sonar-pmd-plugin-2.8.jar:na]
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:58) [sonar-batch-2.8.jar:na]
        at org.sonar.batch.phases.Phases.execute(Phases.java:80) [sonar-batch-2.8.jar:na]
        at org.sonar.batch.ProjectBatch.execute(ProjectBatch.java:59) [sonar-batch-2.8.jar:na]
        at org.sonar.batch.Batch.analyzeModule(Batch.java:164) [sonar-batch-2.8.jar:na]
        at org.sonar.batch.Batch.analyzeModules(Batch.java:82) [sonar-batch-2.8.jar:na]
        at org.sonar.batch.Batch.execute(Batch.java:62) [sonar-batch-2.8.jar:na]
        at org.sonar.runner.Launcher.executeBatch(Launcher.java:60) [sonar-runner.jar:na]
        at org.sonar.runner.Launcher.execute(Launcher.java:53) [sonar-runner.jar:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_23]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [na:1.6.0_23]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [na:1.6.0_23]
        at java.lang.reflect.Method.invoke(Method.java:597) [na:1.6.0_23]
        at org.sonar.runner.Main.delegateExecution(Main.java:111) [sonar-runner.jar:na]
        at org.sonar.runner.Main.execute(Main.java:67) [sonar-runner.jar:na]
        at org.sonar.runner.Main.main(Main.java:48) [sonar-runner.jar:na]

The resolution to the above error is to specify java source and target versions using the advanced parameters named sonar.java.source and sonar.java.target. If you are analyzing using sonar-running you need to specify these properties in the sonar-project.properties file.

Advertisements

Posted on June 17, 2011, in sonar and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: