Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Maven PMD Error with ruleset  RSS feed

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a Maven WebApp project (Just a HelloWorld Servlet) in Eclipse and running tomcat server. My ultimate aim is to fail the build if the code contains out.print statements. I have defined the maven pmd plugin 2.5 in the pom.xml as below and defined a customized ruleset in a file called sop.xml as below.

But when I right click the project -> Run As -> Maven Build and try to package,it is throwing an error as follows,

"Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:2.5:pmd (pmd) on project MavenWebArtifactId: An error has occurred in PMD Report report generation. Could not find resource 'c:\rulesets\sop.xml'".

I am new to Maven and requesting all your kind help on this regard. Thanks.


<?xml version="1.0"?>
<ruleset name="Custom ruleset"
<description>This ruleset checks my code for println statements</description>
<rule ref="rulesets/JavaLogging.xml" message="Must handle exceptions"> </rule>


<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">

Tim Holloway
Posts: 18531
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chances are that your ruleset path is invalid and it's reading "C:\rulesets\sop.xml" as being relative to the project, not relative to the root of the C drive (helpful hint: in Java, usually using Unix-style paths works better).

Maven doesn't like to pull resources from locations outside of the project directory tree (not counting the download/cache mechanism). That's because in theory every Maven project can be collapsed with a "mvn clean" command, zipped, sent to (or from!) Ulan Bator, installed on another machine and completely rebuilt with a single Maven command. You can't do that if there are things that are dependent on the original machine's filesystem layout.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!