Eclipse PMD Cannot find basic.xml

When I try to start for a project in Eclipse / Juno, I get this error.

An internal error occurred during: "ReviewCode". Couldn't find the class Can't find resource rulesets/basic.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH. Here the current classpath: C:\eclipsejuno\eclipse\\plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar 

Does anyone know how I can solve this problem?

+7
source share
6 answers

I also saw this problem with the command line version. In the latest version, the path to the rulesets/java/basic.xml

They seem to have changed the default paths between versions. You either need to manually update your paths in the PMD configuration, or upgrade to the latest version.

+10
source

If there is a ".pmd" file in your project and a referent with ruleset.xml, you can solve your problem by choosing between the above solutions.

  • delete the .pmd file
  • open your ruleset.xml file and your configuration according to this sample
 <rule ref="rulesets/basic.xml" /> 

TO

 <rule ref="rulesets/java/basic.xml" /> 
+5
source

The rule change rule / java / tip helped me, but I also had to change one rule:

 <rule ref="rulesets/java/controversial.xml/UnusedModifier"> <priority>5</priority> </rule> 

to

 <rule ref="rulesets/java/unusedcode.xml/UnusedModifier"> <priority>5</priority> </rule> 

Here is my sonar PMD configuration file that works for me with PMD 4.0.2 plugin .:

 <?xml version="1.0" encoding="UTF-8"?> <ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="pmd-eclipse" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> <rule ref="rulesets/java/basic.xml/UnusedNullCheckInEquals"> <priority>3</priority> </rule> <rule ref="rulesets/java/strings.xml/StringInstantiation"> <priority>3</priority> </rule> <rule ref="rulesets/java/design.xml/ConstructorCallsOverridableMethod"> <priority>3</priority> </rule> <rule ref="rulesets/java/strictexception.xml/AvoidCatchingNPE"> <priority>3</priority> </rule> <rule ref="rulesets/java/strictexception.xml/AvoidRethrowingException"> <priority>3</priority> </rule> <rule ref="rulesets/java/migrating.xml/ReplaceEnumerationWithIterator"> <priority>3</priority> </rule> <rule ref="rulesets/java/optimizations.xml/AvoidArrayLoops"> <priority>3</priority> </rule> <rule ref="rulesets/java/unusedcode.xml/UnusedFormalParameter"> <priority>3</priority> </rule> <rule ref="rulesets/java/basic.xml/ClassCastExceptionWithToArray"> <priority>3</priority> </rule> <rule ref="rulesets/java/strictexception.xml/AvoidThrowingNullPointerException"> <priority>3</priority> </rule> <rule ref="rulesets/java/unusedcode.xml/UnusedPrivateField"> <priority>3</priority> </rule> <rule ref="rulesets/java/design.xml/CompareObjectsWithEquals"> <priority>3</priority> </rule> <rule ref="rulesets/java/strings.xml/UseIndexOfChar"> <priority>3</priority> </rule> <rule ref="rulesets/java/basic.xml/BigIntegerInstantiation"> <priority>3</priority> </rule> <rule ref="rulesets/java/design.xml/FinalFieldCouldBeStatic"> <priority>4</priority> </rule> <rule ref="rulesets/java/naming.xml/SuspiciousEqualsMethodName"> <priority>2</priority> </rule> <rule ref="rulesets/java/design.xml/InstantiationToGetClass"> <priority>3</priority> </rule> <rule ref="rulesets/java/naming.xml/SuspiciousHashcodeMethodName"> <priority>3</priority> </rule> <rule ref="rulesets/java/coupling.xml/LooseCoupling"> <priority>3</priority> </rule> <rule ref="rulesets/java/unusedcode.xml/UnusedLocalVariable"> <priority>3</priority> </rule> <rule ref="rulesets/java/strings.xml/UnnecessaryCaseChange"> <priority>4</priority> </rule> <rule ref="rulesets/java/design.xml/SingularField"> <priority>4</priority> </rule> <rule ref="rulesets/java/design.xml/CloseResource"> <priority>3</priority> </rule> <rule ref="rulesets/java/strictexception.xml/AvoidCatchingThrowable"> <priority>2</priority> </rule> <rule ref="rulesets/java/basic.xml/CollapsibleIfStatements"> <priority>4</priority> </rule> <rule ref="rulesets/java/basic.xml/UselessOperationOnImmutable"> <priority>2</priority> </rule> <rule ref="rulesets/java/clone.xml/CloneMethodMustImplementCloneable"> <priority>3</priority> </rule> <rule ref="rulesets/java/basic.xml/UselessOverridingMethod"> <priority>3</priority> </rule> <rule ref="rulesets/java/unusedcode.xml/UnusedModifier"> <priority>5</priority> </rule> <rule ref="rulesets/java/design.xml/PreserveStackTrace"> <priority>3</priority> </rule> <rule ref="rulesets/java/optimizations.xml/UseArraysAsList"> <priority>3</priority> </rule> <rule ref="rulesets/java/design.xml/EqualsNull"> <priority>2</priority> </rule> <rule ref="rulesets/java/basic.xml/BrokenNullCheck"> <priority>2</priority> </rule> <rule ref="rulesets/java/logging-jakarta-commons.xml/UseCorrectExceptionLogging"> <priority>3</priority> </rule> <rule ref="rulesets/java/strings.xml/InefficientStringBuffering"> <priority>3</priority> </rule> <rule ref="rulesets/java/sunsecure.xml/ArrayIsStoredDirectly"> <priority>2</priority> </rule> <rule ref="rulesets/java/finalizers.xml/FinalizeOverloaded"> <priority>3</priority> </rule> <rule ref="rulesets/java/controversial.xml/DontImportSun"> <priority>4</priority> </rule> <rule ref="rulesets/java/imports.xml/DontImportJavaLang"> <priority>4</priority> </rule> <rule ref="rulesets/java/design.xml/MissingStaticMethodInNonInstantiatableClass"> <priority>3</priority> </rule> <rule ref="rulesets/java/strings.xml/StringBufferInstantiationWithChar"> <priority>3</priority> </rule> <rule ref="rulesets/java/optimizations.xml/UseArrayListInsteadOfVector"> <priority>3</priority> </rule> <rule ref="rulesets/java/strings.xml/StringToString"> <priority>3</priority> </rule> <rule ref="rulesets/java/design.xml/SimplifyConditional"> <priority>3</priority> </rule> <rule ref="rulesets/java/migrating.xml/ReplaceVectorWithList"> <priority>3</priority> </rule> <rule ref="rulesets/java/codesize.xml/NcssMethodCount"> <priority>3</priority> <properties> <property name="minimum" value="50" /> </properties> </rule> <rule ref="rulesets/java/logging-java.xml/AvoidPrintStackTrace"> <priority>3</priority> </rule> <rule ref="rulesets/java/naming.xml/MethodWithSameNameAsEnclosingClass"> <priority>3</priority> </rule> <rule ref="rulesets/java/naming.xml/SuspiciousConstantFieldName"> <priority>3</priority> </rule> <rule ref="rulesets/java/codesize.xml/NcssTypeCount"> <priority>3</priority> <properties> <property name="minimum" value="800" /> </properties> </rule> <rule ref="rulesets/java/design.xml/AvoidInstanceofChecksInCatchClause"> <priority>4</priority> </rule> <rule ref="rulesets/java/migrating.xml/IntegerInstantiation"> <priority>3</priority> </rule> <rule ref="rulesets/java/migrating.xml/AvoidAssertAsIdentifier"> <priority>3</priority> </rule> <rule ref="rulesets/java/design.xml/UnnecessaryLocalBeforeReturn"> <priority>3</priority> </rule> <rule ref="rulesets/java/finalizers.xml/AvoidCallingFinalize"> <priority>3</priority> </rule> <rule ref="rulesets/java/basic.xml/BooleanInstantiation"> <priority>3</priority> </rule> <rule ref="rulesets/java/basic.xml/UnconditionalIfStatement"> <priority>2</priority> </rule> <rule ref="rulesets/java/clone.xml/CloneThrowsCloneNotSupportedException"> <priority>3</priority> </rule> <rule ref="rulesets/java/migrating.xml/ReplaceHashtableWithMap"> <priority>3</priority> </rule> <rule ref="rulesets/java/basic.xml/AvoidDecimalLiteralsInBigDecimalConstructor"> <priority>3</priority> </rule> <rule ref="rulesets/java/strictexception.xml/SignatureDeclareThrowsException"> <priority>3</priority> </rule> <rule ref="rulesets/java/finalizers.xml/EmptyFinalizer"> <priority>3</priority> </rule> <rule ref="rulesets/java/design.xml/IdempotentOperations"> <priority>3</priority> </rule> <rule ref="rulesets/java/strictexception.xml/ExceptionAsFlowControl"> <priority>3</priority> </rule> <rule ref="rulesets/java/finalizers.xml/FinalizeDoesNotCallSuperFinalize"> <priority>3</priority> </rule> <rule ref="rulesets/java/strings.xml/UseStringBufferLength"> <priority>4</priority> </rule> <rule ref="rulesets/java/migrating.xml/AvoidEnumAsIdentifier"> <priority>3</priority> </rule> <rule ref="rulesets/java/logging-java.xml/SystemPrintln"> <priority>3</priority> </rule> <rule ref="rulesets/java/strings.xml/UselessStringValueOf"> <priority>4</priority> </rule> <rule ref="rulesets/java/strings.xml/AvoidDuplicateLiterals"> <priority>3</priority> </rule> </ruleset> 
+3
source

I was getting this error when trying to update a Maven project in Eclipse. The problem for me was that I used two different PMDs, one of which was installed as an Eclipse plugin, and the other was loaded by Maven from the pom.xml file of the parent project. So I needed to do this to remove the Eclipse PMD plugin and after that no longer got the error.

+2
source

In my case, I have my own pmdRuleSet.xml file and it looks like this:

 <rule ref="pmd-rulesets/java/codesize.xml/ExcessiveMethodLength"> <properties> <property name="minimum" value="10"/> </properties> 

And it throws an error if I change "pmd-rulesets" to "ruleset" and the path in pmdRuleSet.xml, obviously then everything is ok.

0
source

if you have to deal with complex project settings, you can use this line to convert each .pmd file

 find . -name .pmd -exec sed -i.bak 's/rulesets\/basic.xml/rulesets\/java\/basic.xml/g' {} \; 
0
source

All Articles