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( [pmd-4.2.5.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.ImportDeclaration( [pmd-4.2.5.jar:na]
        at net.sourceforge.pmd.ast.JavaParser.CompilationUnit( [pmd-4.2.5.jar:na]
        at net.sourceforge.pmd.parsers.Java14Parser.parse( [pmd-4.2.5.jar:na]
        at net.sourceforge.pmd.PMD.processFile( [pmd-4.2.5.jar:na]
        at net.sourceforge.pmd.PMD.processFile( [pmd-4.2.5.jar:na]
        at org.sonar.plugins.pmd.PmdExecutor.execute( [sonar-pmd-plugin-2.8.jar:na]
        at org.sonar.plugins.pmd.PmdSensor.analyse( [sonar-pmd-plugin-2.8.jar:na]
        at org.sonar.batch.phases.SensorsExecutor.execute( [sonar-batch-2.8.jar:na]
        at org.sonar.batch.phases.Phases.execute( [sonar-batch-2.8.jar:na]
        at org.sonar.batch.ProjectBatch.execute( [sonar-batch-2.8.jar:na]
        at org.sonar.batch.Batch.analyzeModule( [sonar-batch-2.8.jar:na]
        at org.sonar.batch.Batch.analyzeModules( [sonar-batch-2.8.jar:na]
        at org.sonar.batch.Batch.execute( [sonar-batch-2.8.jar:na]
        at org.sonar.runner.Launcher.executeBatch( [sonar-runner.jar:na]
        at org.sonar.runner.Launcher.execute( [sonar-runner.jar:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_23]
        at sun.reflect.NativeMethodAccessorImpl.invoke( [na:1.6.0_23]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke( [na:1.6.0_23]
        at java.lang.reflect.Method.invoke( [na:1.6.0_23]
        at org.sonar.runner.Main.delegateExecution( [sonar-runner.jar:na]
        at org.sonar.runner.Main.execute( [sonar-runner.jar:na]
        at org.sonar.runner.Main.main( [sonar-runner.jar:na]

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


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: Logo

You are commenting using your 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: