ant junit build error inside eclipse

18,952

Solution 1

I experienced the same stylesheet problem within Eclipse using the following environment:

  • Windows 7 x64
  • Eclipse 3.7.2 (SR2) 32-bit
  • JDK 1.6.0_32 32-bit
  • Ant 1.7.2 (from Eclipse) or 1.7.4 (from Apache, current)
  • Junit 4.8.1 (project dependency)

My build succeeds while using JDK 1.6.0_31, so it appears the stylesheet problem is an Ant or Java bug introduced with the release of Java 6 build 32. I could not find any reports in Apache's Bugzilla system. If it helps someone, these are the bug fixes included in build 32: http://www.oracle.com/technetwork/java/javase/2col/6u32bugfixes-1579554.html

My current workaround is to use Java 6 JDK build 31.

Update: Workaround to use a newer JDK

The Ant failures from within Eclipse started with a defect introduced in Java 6u32 and Java7u4. The saga is reported in Eclipse Bug #384757, including a workaround allowing you to use newer JDKs.

  • Download the org.apache.xalan and org.apache.xml.serializer plug-ins from the Eclipse Orbit project
  • Copy them to a directory listed in the Java java.ext.dirs property

I use the following directories because they are defined by default and independent of JDK version:

  • On Windows: C:\Windows\Sun\Java\lib\ext
  • On Mac: /Users/$USER/Library/Java/Extensions

The root problem was reported to Oracle, but the bug is no longer in their bug database. I am not optimistic it will ever be fixed.

Update: Apache fixed the problem in Ant

Apache has fixed the root problem; it may be available in the Ant 1.9.0 release (Apache Bug #54641).

Update: Ant 1.9.1 scheduled for Eclipse 4.4

As @OliBlogger mentioned, Apache fixed the root problem in Ant 1.9.1. Eclipse plans to update to Ant 1.9.1 in Eclipse 4.4 (perhaps sooner, the Eclipse bug system does not yet have 4.3.x milestones).

Update: Fixed in Eclipse 4.4

I confirmed that my build now succeeds using Java 7 JDK build 67 and Ant 1.9.2 distributed with Eclipse 4.4.1 (Windows 7) without using the Orbit plug-in workaround.

Solution 2

Please try to go to Preferences->Ant->Runtime and set the Ant Home... there to your ant installation folder. By default eclipse comes with and uses an ant contributed as a plug-in.

You can also add there additional jars, folders if needed.

Solution 3

It was stated in https://bugs.eclipse.org/bugs/show_bug.cgi?id=384757#c18 that the fix for this was in Ant 1.9 but unfortunately it seems to be sechduled for 1.9.1 now. So in the mean time this worked for me.

You can use the style sheets from http://svn.apache.org/viewvc?view=revision&revision=1453414. Then add "stledir" to the report tag. example: styledir="c:\utils"

Share:
18,952
Tuan
Author by

Tuan

Updated on June 29, 2022

Comments

  • Tuan
    Tuan almost 2 years

    I am hoping there are some people who have seen and have a solution for the problem that I am having right now with ant script. I am using an ant script to compile my java codes in eclipse but eclipse keeps giving me these errors

    [junitreport] Processing E:\workspace\DataOrchestrationDevelopment\DataOrchestration\Logs\jsreports\junit\html\TESTS-TestSuites.xml to C:\Users\u0160235\AppData\Local\Temp\null1503375679
    [junitreport] Loading stylesheet jar:file:/E:/software/apache/apache-ant-1.8.2/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 E:\workspace\DataOrchestrationDevelopment\DataOrchestration\Logs\jsreports\junit\html\TESTS-TestSuites.xml
    
    BUILD FAILED
    E:\workspace\DataOrchestrationDevelopment\DataOrchestration\ant\developerbuild.xml:124: The following error occurred while executing this line:
    E:\workspace\DataOrchestrationDevelopment\DataOrchestration\ant\QunitAntScript.xml:20: Errors while applying transformations: Fatal error during transformation
    

    My environment settings:

    • Windows 7
    • Eclipse 3.6 RC2 32 bit
    • JDK 1.6 update 32 32 bit
    • Ant 1.7.2
    • Junit 4 (within eclipse): in my project jar folder I have junit-dep-4.8.2.jar

    One thing to mention that if I compile my codes outside eclipse using the same ant script, everything works just fine, but it doesn't work inside eclipse. I tried to google the errors above the stylesheet above, but that didn't help me much. My guess is somehow, within eclipse different version of junit is being used, but I might be wrong.

  • Tuan
    Tuan almost 12 years
    Thanks for quick reply. I set my ant home to the ant installation folder, but that didn't help me resolve those errors.
  • Tuan
    Tuan almost 12 years
    I'd also like to know if I need to add any additional jar files for ant (running inside my eclipse) to resolve those files? If I do need to add more jar files, what would those be and where would I add them?
  • Jan Arciuchiewicz
    Jan Arciuchiewicz almost 12 years
    The same place in preferences.
  • Jan Arciuchiewicz
    Jan Arciuchiewicz almost 12 years
    Also make sure that you define the same Java Runtime Env. (by default eclipse will use default JRE and you probably want to use your JDK instead). To set it use (Preferences->Java->Installed JRE's)
  • Tuan
    Tuan almost 12 years
    yes, I did that but that still not resolve the problem. The mentioned environment settings in my initial post were what I applied in eclipse settings.
  • Tuan
    Tuan almost 12 years
    FYI, I gave up the idea of finding the solution for this. Instead I just execute the ant script from the command line using batch file.
  • Tyler Treat
    Tyler Treat almost 12 years
    @Tuan -- use JDK 1.6 u31 instead of 32. I was having the same problems but this fixed it!
  • Steven Darnell
    Steven Darnell almost 12 years
    @Tyler, sorry I missed your comment. It was hidden by a show more comments link.
  • Steven Darnell
    Steven Darnell almost 12 years
    I still have not found a real solution to the problem. I reported the bug to Eclipse: Bug 384757.
  • Tuan
    Tuan over 11 years
    Another workaround solution is to execute the ant script outside of Eclipse. This worked for me without changing my current jdk.
  • OliCoder
    OliCoder over 11 years
    The same issue happens to me using NetBeans. I went back to JDK 1.6.0_31.
  • Steven Darnell
    Steven Darnell about 11 years
    The workaround is required for those who are building RCP applications with the Eclipse PDE build system, regardless if the build is initiated from the IDE or the command line. It looks like it is not required for Java applications not directly dependent on Eclipse.
  • OliCoder
    OliCoder about 11 years
    Just read the update to your answer (Apache fixed the problem in Ant. Apache has fixed the root problem; it may be available in the Ant 1.9.0 release (Apache Bug #54641)). Which is good news. However, the target release for the fix is 1.9.1. Current release version is 1.8.4.