• 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"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"
<description>This ruleset checks my code for println statements</description>
<rule ref="rulesets/JavaLogging.xml" message="Must handle exceptions"> </rule>


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

Tim Holloway
Posts: 18662
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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!