Error! The first argument to the non-static Java function 'replace' is not a valid object reference

ant, eclipse, junit

Solution

When I got this error I had to right click on my build.xml file in Eclipse, choose the "Run as Ant build..." option (3rd one in the menu) then click the JRE tab and select the "Run in the same JRE as the workspace" option and then proceeded to run the script. For some reason this fixed the problem. I honestly don't know why.

Problem

I am trying to get ANT to create an HTML report of a JUNIT test in Eclipse but after I created the ANT build I get the following errors when I run it: ``` [junitreport] Processing C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml to C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\null785926900 [junitreport] Loading stylesheet jar:file:/C:/ANT/apache-ant-1.8.3/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:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml ``` What do I need to do to fix this? Here are the sections of my Build.xml I am trying to run: ``` <target name="Home"> <mkdir dir="${junit.output.dir}"/> <junit fork="yes" printsummary="withOutAndErr"> <formatter type="xml"/> <test name="Home" todir="${junit.output.dir}"/> <classpath refid="Home.classpath"/> </junit> </target> <target name="junitreport"> <junitreport todir="${junit.output.dir}"> <fileset dir="${junit.output.dir}"> <include name="TEST-*.xml"/> </fileset> <report format="frames" todir="${junit.output.dir}"/> </junitreport> </target> ```

Original source