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

2

6

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?

Pice answered 23/11, 2011 at 10:12 Comment(0)
J
3

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.

Jacie answered 25/1, 2012 at 16:42 Comment(0)
B
0

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.

You can always just comment the task out.

Billyebilobate answered 1/12, 2011 at 8:19 Comment(1)
Thanks for your answer. Perhaps my sentence wasn't all clear. I'd like to disable the 'secure processing feature' but I do need the junitreport.Pice

© 2022 - 2024 — McMap. All rights reserved.