Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant Build Error in Eclipse IDE for Java

I have been receiving the following error and have done a lot of research and tried all of the offered solutions to no avail.

junitreport:
 [junitreport] Processing C:\workspace\test123\junit\TESTS-TestSuites.xml to C:\Users\Matt\AppData\Local\Temp\null1903337257
 [junitreport] Loading stylesheet jar:file:/C:/Users/Matt/Documents/Selenium/eclipse/plugins/org.apache.ant_1.8.3.v20120321-1730/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
 [junitreport] : Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
 [junitreport] : Error! Cannot convert data-type 'void' to 'reference'.
 [junitreport] : Fatal Error! Could not compile stylesheet
 [junitreport] Failed to process C:\workspace\test123\junit\TESTS-TestSuites.xml

BUILD FAILED
C:\Users\Matt\workspace\Test1\build.xml:122: Errors while applying transformations: Fatal error during transformation

I found a solution at ant junit build error inside eclipse and saying that the issue was caused by a newer version of JDK and using 1.6_31 would solve it and I tried that following instructions I found online on how to change the version of Java eclipse is using. Every time I run the build ant it returns the same error regardless of which version of Java I am using. I have tried JRE7, jdk1.7.0_05, jdk1.6.0, jdk1.6.0_31 and others that I don't have installed anymore.

I am running the following

  • Windows 7 Pro SP1 x64
  • Eclipse IDE for Java Developers Version: Juno Release Build id: 20120614-1722
  • org.apache.ant_1.8.3.v20120321-1730

If anyone could provide any assistance in getting this report running it would be greatly appreciated. I'm new to programming and this is very frustrating especially since I'm still learning all of the jargon and trying to be sure I am following the instructions properly. If you require anymore information from me I will provide it and I will follow any instruction given to the best of my ability. Thank you very much in advance.

like image 529
Matthew Helfgott Avatar asked Aug 02 '12 21:08

Matthew Helfgott


2 Answers

While an Ant Bug Report 384757 claims that this is caused by the XSL Tranformer build into the Oracle JDK - which may be true - the problem can be fixed by changing the Ant version:

I tried some of the workarounds mentioned there. After a while, I found that the bug appears with Ant 1.8.3 (distributed in Eclipse), but not with Ant 1.8.2 (distributed in Eclipse 3.7).

The bug also does not appear with Ant 1.9.0.

I have downloaded Ant 1.9.0 and in configured Eclipse's "Run As -> Ant build..." to use the Ant 1.9.0 folder as ANT HOME. This worked.

PS: My Eclipse used Ant 1.8.3 (which did not work), but running Ant from the console used Ant 1.8.2 (which worked). This was confusing at first.

like image 183
Christian Fries Avatar answered Oct 01 '22 13:10

Christian Fries


I have solved the issue by downloading apache-ant-1.9.1 and configuring it in Eclipse by changing the ANT HOME from windows--> Preferences and setting the ANT HOME to apache-ant-1.9.1.

like image 26
user2447601 Avatar answered Oct 01 '22 15:10

user2447601