Troubles with Jenkins pmd plugin

1,073 views
Skip to first unread message

Jonathan Araque

unread,
Apr 5, 2011, 10:44:29 AM4/5/11
to Jenkins Users
Hello there,

I'm trying to execute a pmd check but I'm getting the following
errors:
I'm using jenkins v 1.404 and the pmd plugin v 3.14

PMD error:

Module conf: Parsing of file /path/to/pmd.xml failed due to an
exception: org.xml.sax.SAXException: Input stream is not a PMD file.
at hudson.plugins.pmd.parser.PmdParser.parse(PmdParser.java:73) at
hudson.plugins.analysis.core.AbstractAnnotationParser.parse(AbstractAnnotationParser.java:
52) at
hudson.plugins.analysis.core.FilesParser.parseFile(FilesParser.java:
197) at
hudson.plugins.analysis.core.FilesParser.parseFiles(FilesParser.java:
176) at
hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:126)
at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:
29) at hudson.FilePath.act(FilePath.java:757) at
hudson.FilePath.act(FilePath.java:739) at
hudson.plugins.pmd.PmdPublisher.perform(PmdPublisher.java:134) at
hudson.plugins.analysis.core.HealthAwarePublisher.perform(HealthAwarePublisher.java:
281) at hudson.tasks.BuildStepMonitor$2.perform(BuildStepMonitor.java:
27) at hudson.model.AbstractBuild
$AbstractRunner.perform(AbstractBuild.java:649) at
hudson.model.AbstractBuild
$AbstractRunner.performAllBuildSteps(AbstractBuild.java:625) at
hudson.model.AbstractBuild
$AbstractRunner.performAllBuildSteps(AbstractBuild.java:603) at
hudson.model.Build$RunnerImpl.post2(Build.java:161) at
hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:572)
at hudson.model.Run.run(Run.java:1386) at
hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at
hudson.model.ResourceController.execute(ResourceController.java:88) at
hudson.model.Executor.run(Executor.java:145)

The built is ok, but the warnings pmd displays are 0 ( I know there
are lots more than that )

I apreciate any clue!

Thanks

Ullrich Hafner

unread,
Apr 5, 2011, 11:12:33 AM4/5/11
to jenkins...@googlegroups.com
Did you check if the specified pmd.xml file actually is a pmd results
file that contains warnings?

Ulli

Message has been deleted
Message has been deleted

Jonathan Araque

unread,
Apr 5, 2011, 12:17:26 PM4/5/11
to Jenkins Users
Yes I did. Indeed that was the first thing I did, but I've tried that
one in netbeans and it works fine. Actually I'm searching any other
pmd.xml file to check it, if you have one you've tried I'll check it
inmediatly.

Here's my pmd.xml file content:

<?xml version="1.0"?>
<ruleset xmlns="http://pmd.sf.net/ruleset/1.0.0" name="pmd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/
ruleset_xml_schema.xsd"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd">

<description>Ullis PMD rules.</description>

<rule ref="rulesets/basic.xml">
<exclude name="EmptyCatchBlock"/>
</rule>
<rule ref="rulesets/basic.xml/EmptyCatchBlock">
<properties>
<property name="allowCommentedBlocks" value="true"/>
</properties>
</rule>
<rule ref="rulesets/braces.xml"/>
<rule ref="rulesets/clone.xml"/>
<rule ref="rulesets/codesize.xml">
<exclude name="CyclomaticComplexity"/>
<exclude name="TooManyMethods"/>
</rule>
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties>
<property name="showClassesComplexity" value="false"/>
</properties>
</rule>
<rule ref="rulesets/controversial.xml">
<exclude name="AtLeastOneConstructor"/>
<exclude name="DataflowAnomalyAnalysis"/>
<exclude name="BooleanInversion"/>
<exclude name="OnlyOneReturn"/>
<exclude name="DefaultPackage"/>
</rule>
<rule ref="rulesets/coupling.xml"/>
<rule ref="rulesets/design.xml">
<exclude name="EmptyMethodInAbstractClassShouldBeAbstract"/>
<exclude name="UseSingleton"/>
<exclude name="AvoidSynchronizedAtMethodLevel"/>
<exclude name="CloseResource"/>
<exclude name="AbstractClassWithoutAbstractMethod"/>
</rule>
<rule ref="rulesets/finalizers.xml"/>
<rule ref="rulesets/imports.xml">
<exclude name="UnusedImports"/>
</rule>
<rule ref="rulesets/junit.xml">
<exclude name="JUnitTestsShouldIncludeAssert"/>
</rule>
<rule ref="rulesets/naming.xml">
<exclude name="ShortVariable"/>
<exclude name="LongVariable"/>
<exclude name="AbstractNaming"/>
</rule>
<rule ref="rulesets/optimizations.xml">
<exclude name="LocalVariableCouldBeFinal"/>
<exclude name="SimplifyStartsWith"/>
<exclude name="AvoidInstantiatingObjectsInLoops"/>
<exclude name="UseStringBufferForStringAppends"/>
</rule>
<rule ref="rulesets/strictexception.xml"/>
<rule ref="rulesets/strings.xml">
<exclude name="AvoidDuplicateLiterals"/>
</rule>
<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals">
<properties>
<property name="skipAnnotations" value="true"/>
</properties>
</rule>
<rule ref="rulesets/sunsecure.xml"/>
<rule ref="rulesets/unusedcode.xml"/>
<rule ref="rulesets/logging-java.xml/SystemPrintln">
<priority>3</priority>
</rule>
<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace">
<priority>3</priority>
</rule>
</ruleset>

Thanks a lot!
Message has been deleted

Ulli Hafner

unread,
Apr 5, 2011, 1:21:46 PM4/5/11
to jenkins...@googlegroups.com
I'm not sure if I understand: your file is a PMD configuration file, not
a results file. The PMD Jenkins plug-in can't read this file! This file
should be the input file for your build tool.

You need to pass the results of the PMD build step to the PMD plug-in.

Ulli

On 04/05/2011 05:51 PM, Jonathan Araque wrote:
> Yes I did. Indeed that was the firt thing I did, but I've tried that


> one in netbeans and it works fine. Actually I'm searching any other
> pmd.xml file to check it, if you have one you've tried I'll check it
> inmediatly.
>

> Here is my pmd.xml file

> Thanks a lot!!!


>
> On 5 abr, 10:12, Ullrich Hafner<ullrich.haf...@gmail.com> wrote:

Jonathan Araque

unread,
Apr 5, 2011, 2:39:31 PM4/5/11
to Jenkins Users
Ok, now I'm getting it clearer. I was REALLY WRONG about the process.

If I'm not wrong the process should be:
- Build the project and run pmd with the pmd-config.xml so I can get
the pmd-result.xml
- Use the pmd-plugin so I can view the results....
Is this all right?

How can I build the project aiming to the pmd-configuration.xml file
so I can get de pmd-result.xml file?
Where do I have to put de pmd-configuration.xml file and how do I
configure jenkins to make it posible?

Thanks a lot!

Manuel Doninger

unread,
Apr 5, 2011, 3:04:21 PM4/5/11
to jenkins...@googlegroups.com
On Tue, Apr 5, 2011 at 20:39, Jonathan Araque <jaap...@gmail.com> wrote:
> Ok, now I'm getting it clearer. I was REALLY WRONG about the process.
>
> If I'm not wrong the process should be:
> - Build the project and run pmd with the pmd-config.xml so I can get
> the pmd-result.xml
> - Use the pmd-plugin so I can view the results....
> Is this all right?

Yes.

>
> How can I build the project aiming to the pmd-configuration.xml file
> so I can get de pmd-result.xml file?
> Where do I have to put de pmd-configuration.xml file and how do I
> configure jenkins to make it posible?

Which build tool do you use? If you use Maven, then the
maven-pmd-plugin would do the job for you in its default
configuration. If you use another build tool, then you have to look
for a possibility to invoke PMD (there are e.g. anttasks for PMD).

Manuel

Jonathan Araque

unread,
Apr 5, 2011, 6:12:13 PM4/5/11
to Jenkins Users
Ok, i'm trying to build it with ANT ( also I'm new at this), but I
have:
/built.xml
/nbproject/built-impl.xml
/nbproject/ant-deploy.xml

I've already configured JDK_HOME, ANT_HOME but still having errors
while building the project with jenkins.

First I had the folowing error:

The Java EE server classpath is not correctly set up - server home
directory is missing.
Either open the project in the IDE and assign the server or setup the
server classpath manually.
For example like this:
ant -Dj2ee.server.home=<app_server_installation_directory>


And I "resolve-it" writting down at the configuration page in
destinatios input_text:
ant -Dj2ee.server.home=</path/to/glassfish-3.0.1/>

But NOW I have this error:
BUILD FAILED
Target "ant" does not exist in the project "myproject".

:S

I'm still searching.....

If you have any clue......


thanks a lot!!

On 5 abr, 14:04, Manuel Doninger <man...@doninger.net> wrote:

Brian Smith

unread,
Apr 5, 2011, 8:31:28 PM4/5/11
to jenkins...@googlegroups.com, Jonathan Araque
Hi Jonathan

The last problem you mention would seem to indicate you have configured the job in jenkins to run the target "ant".  You don't need to do that, ant is the executable.  Targets are optional, if none are specified ant will run the target defined as the default in your build xml.

I am guessing your ant build files there are generated by netbeans?  From the looks of it they do more than you might usually need for continuous integration including deploying to an app server.  It may be that you want to find some targets in the build.xml that are more specific than the default one.  Sorry I can't be more specific but I don't know what's normally in netbeans generated ant builds.

In any case. I think you're having a bit of difficulty with where ant ends and jenkins begins so it might be easier to just take jenkins out of the loop for now - I'd recommend you try first to get a working ant build without using jenkins. 

That is, from the command line you are able to execute "ant clean <target1>..." and have it build your jar(s), run your tests and produce your PMD results.   You'll need to look at example ant targets from the pmd website and generic ant examples from its website at apache.  Ant isn't much fun I'm afraid.  When this works, configuring your jenkins install to run that build is very easy.  All it really does is run that command line and then look for the outputs you configure.

Good luck

Brian

Jonathan Araque

unread,
Apr 6, 2011, 8:37:19 AM4/6/11
to Jenkins Users
Hi Brian,

Yes I'm working with NetBeans and it writes all the building files.
I don't need ANT what I need is the easiest way to run pmd and
checkstyle analisys so it helps me to see the results by Jenkins pmd
and checkStyle plug-in.

I also need some kind of integration with SONAR... I don't know....
maybe that pmd and checkstyle analisys is made by SONAR...

Also I already know the Jenkins pmd plugin is working fine with the
pmd-result.xml file, so I think maybe this problem is out of the
topic.. Should I open a new one?

Thank you very much!

Jonathan Araque

unread,
Apr 6, 2011, 7:02:28 PM4/6/11
to Jenkins Users
Hello there,

After one long google-ing day I finally solve my problems using maven:

pom.xml -> I had to write down the reporting tags:
<project....
....
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.6</version>
<configuration>
<configLocation>checkstyle-config.xml</
configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<rulesets>
<!-- this "../" is not a good practice but it
works-->
<ruleset>../pmd-config.xml</ruleset>
</rulesets>
<sourceEncoding>utf-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.5</targetJdk>
</configuration>
</plugin>

</plugins>
</reporting>
</project>


Jenkins -> I had to write down "checkstyle:checkstyle pmd:pmd" in the
Goals input-text

I'm still looking for figuring out how to do it without
maven........ :S


Thanks a lot!!!
Reply all
Reply to author
Forward
Message has been deleted
0 new messages