File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven PMD Error with ruleset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven PMD Error with ruleset" Watch "Maven PMD Error with ruleset" New topic

Maven PMD Error with ruleset


Joined: Jan 06, 2007
Posts: 6

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
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Maven PMD Error with ruleset
It's not a secret anymore!