Labels

Tuesday, June 19, 2012

java.lang.reflect.InvocationTargetException

Tried running out-of-the-box Findbugs 1.3 with Ant 1.6 and Ant 1.7, on JDK 1.4 and JDK 1.5
It throws an error for the task findbugs.report which is a simple XSLT transform using a stylesheet. Peculiarly this fails only on Windows but works fine on Unix.
build.xml contains:


<style
basedir="${build.report.temp}"
destdir="${build.report}/findbugs"
includes="findbugs-post.xml"
style="${script.tools}/findbugs/tools/xsl/report.xsl">
<param
name="messages.xml"
expression="${script.tools}/findbugs/tools/xsl/messages.xml"/>
<param
name="output.dir"
expression="${build.report}/findbugs"/>
</style>


The error is


[style] Processing D:\Construction\reports\ebilling\tmp\findbugs-post.xml to D:\Construction\reports\ebilling\findbugs\findbugs-post.html 
[style] Loading stylesheet D:\Construction\buildtools\bin\findbugs\tools\xsl\report.xsl 
[style] : Error! java.lang.reflect.InvocationTargetException 
[style] Failed to process D:\Construction\reports\ebilling\tmp\findbugs-post.xml
BUILD FAILED


D:\Construction\buildtools\dbscripts\findbugs.xml:67: javax.xml.transform.TransformerException: com.sun.org.apache.xalan.internal.xsltc.TransletException: java.lang.reflect.InvocationTargetException



The problem is the <param> passed in with an absolute path fails for some reason - but it works when the path is relative to the stylesheet referenced in the style attribute. In this case the stylesheet is at style="${script.tools}/findbugs/tools/xsl/report.xsl"
So we changed:



<param expression="${script.tools}/findbugs/tools/xsl/messages.xml" name="messages.xml">


to a path relative to the report.xsl

<param expression="./messages.xml" name="messages.xml">
and that worked.

No comments:

Post a Comment