Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant <junitreport> fail because of Xalan's (XSLT) secure processing feature

My junit tests run via ant 1.7 from within my Eclipse environment but the build failes when the junitreport task is performed:

BUILD FAILED .../build.xml:222: Errors while applying transformations: javax.xml.transform.TransformerException: java.lang.RuntimeException: Use of the extension function 'xalan://org.apache.tools.ant.util.StringUtils:replace' is not allowed when the secure processing feature is set to true.

I tried to figure out how to make the junitreport task disable the secure processing feature (which I don't need and is only in my way at this point) but I have no clue how since the task doesn't have an attribute to disable it. Or should I do something else to make this work?

like image 842
Almer Avatar asked Nov 23 '11 10:11

Almer


1 Answers

This may be related to a very similar known bug in Ant 1.8.2.

The bugfix for Ant 1.8.3 has been committed, but Apache Ant 1.8.3 has yet to be released as of Jan 25 2012. The WHATSNEW description for this bugfix is:

<junitreport> did not work in embedded environments on JDK 7.
Bugzilla Report 51668.

Once Ant 1.8.3 is released and is incorporated into the Eclipse Ant plugin, this issue should be resolved.

In the meantime, you can edit your build script so it only runs the JUnitReport target if running Ant from a command line, rather than from within Eclipse. To make this determination, look for a file present in your regular %ANT_HOME%/lib folder that is not present in your Eclipse Ant plugin folder (or create a file there), then set a property if the file is detected. E.G.

Just before the end of your JUnit target:

<available file="${ant.home}/lib/ant.pom" property="full.ant"/>

At the beginning of your JUnitReport target:

  <target name="junitreport" description="Create a consolidated test results report" if="full.ant">

The above Ant fragments work because ant.home is set to the Eclipse Ant Plugin folder only when Ant is run from within Eclipse. When Ant is run from a command line, ant.home will match your ANT_HOME environment variable. There is also supposed to be an eclipse.running Ant property, but I could not detect this property.

Another interim option is to download the newest JAR files of Ant nightly builds from this link on the Apach Ant project page, then placing those JAR files within the corresponding Eclipse Ant plugin sub-folder. No guarantees this will work.

like image 68
MikeOnline Avatar answered Sep 27 '22 21:09

MikeOnline