Search code examples
antpmd

Could not initialize class net.sourceforge.pmd.lang.xpath.Initializer


Here is my pmd script for ant build.xml

<property name="pmd.dir" value="${basedir}/pmd" /><!-- directory that contains pmd.jar -->
<property name="pmd.test.results" location="${build.dir}/pmd"/>
<path id="pmd.lib" >
    <fileset dir="${pmd.dir}">
        <include name="*.jar"/>
        <exclude name="/rulesets" />
    </fileset>
</path>
<target name="pmd" depends="compile" >
     <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.lib"/>
     <pmd shortFilenames="true">
           <ruleset>b</ruleset>
           <formatter type="text" toFile="pmd-ant-results.txt"/>
           <fileset dir="src">
                 <include name="**/*.java"/>
           </fileset>
     </pmd>
</target>

Here is a screen shot of my projects explorer, here is a pastebin link to ruleset.xml

projects
(source: iforce.co.nz)

And here is the error

pmd:

BUILD FAILED C:\Users\Michael\Desktop\log4jassignment.s06005586\build.xml:112: Can't find resource ruleset/java/basic.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH. Here's the current classpath: C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-antlr.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-apache-bcel.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-apache-bsf.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-apache-log4j.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-apache-oro.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-apache-regexp.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-apache-resolver.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-apache-xalan2.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-commons-logging.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-commons-net.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-jai.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-javamail.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-jdepend.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-jmf.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-jsch.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-junit.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-junit4.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-launcher.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-netrexx.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-swing.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant-testutil.jar;C:\Program Files\eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\lib\ant.jar;C:\Program Files\eclipse\configuration\org.eclipse.osgi\bundles\57\2.cp\lib\antdebug.jar;C:\Program Files\eclipse\configuration\org.eclipse.osgi\bundles\57\2.cp\lib\remote.jar;C:\Program Files\eclipse\configuration\org.eclipse.osgi\bundles\58\2.cp\lib\remoteAnt.jar;C:\Program Files\Java\jdk1.6.0_25\lib\tools.jar;C:\Program Files\eclipse\plugins\org.eclipse.swt.win32.win32.x86_64_3.100.0.v4233d.jar;C:\Users\Michael\Desktop\log4jassignment.s06005586\tools\jdepend-2.9.1.jar

The main problem I'm having is lack of information regarding pmd and ant (its terrible there is nothing out there) so I'm pretty much lost at this point at what I'm doing wrong... I'm pretty sure I havent set up my rulesets correctly (but there isn't a way to tell because of this lack of information for ant/pmd implementations)....


Solution

  • The error clearly says...

    BUILD FAILED C:\Users\Michael\Desktop\log4jassignment.s06005586\build.xml:112: Can't find resource ruleset/java/basic.xml 
    

    and I don't see java folder inside ruleset. So get the folder and files in right place and then see whether it works or not