ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Domagoj Jugovic <doma...@laus.hr>
Subject junit task not working
Date Fri, 14 Jun 2002 14:03:36 GMT
<LOOP times="999999999999" message="PLEASE HELP !!!" />
I am running ant (1.4 and 1.5b2) on win98 , the build did'n work on 1.4 so 
I reached out for 1.5 and it's not working either.

I have a target called "junit" :
....................
<target name="junit" description="Performs all JUnit regression tests." >
<junit printsummary="yes" fork="yes" dir="${build.test}/ojb">
<classpath refid="runtime-classpath"/>
<formatter type="plain" />
<test name="test.ojb.broker.AllTests"
haltonfailure="no"
outfile="target/test/tests-broker" >
</test>
<test name="test.ojb.odmg.AllTests"
haltonfailure="no"
outfile="target/test/tests-odmg" >
</test>
<test name="test.ojb.soda.AllTests"
haltonfailure="no"
outfile="target/test/tests-soda" >
</test>
</junit>
</target>
...................

on that target I get printout like :
..................
junit:
BUILD FAILED
C:\java\ojb9\build.xml:407: Could not create task or type of type: junit.
Ant could not find the task or a class this task relies upon.
This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
- You have misspelt 'junit'.
Fix: check your spelling.
- The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
- The task is an Ant optional task and optional.jar is absent
Fix: look for optional.jar in ANT_HOME/lib, download if needed
- The task was not built into optional.jar as dependent
libraries were not found at build time.
Fix: look in the JAR to verify, then rebuild with the needed
libraries, or download a release version from apache.org
- The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
- The task is not an Ant core or optional task
and needs to be declared using <taskdef>.
............................

So I tried to fix things by manualy defining taskdef for "junit" task.
At the beginning of the build.xml I added :
<taskdef name="junit" 
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" 
classpathref="runtime-classpath"/>
Then I got this printout (Failing at my taskdef) :
..................
BUILD FAILED
C:\java\ojb9\build.xml:36: taskdef class 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java)
at 
org.apache.tools.ant.helper.ProjectHelperImpl$TaskHandler.finished(ProjectHelperImpl.java)


at 
org.apache.tools.ant.helper.ProjectHelperImpl$AbstractHandler.endElement(ProjectHelperImpl.java)


at 
org.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:552) 

at 
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:217)


at 
org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(XMLNamespaceBinder.java:594) 

at 
org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:817) 

at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:748)


at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1454)


at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)


at 
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:529)


at 
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:585)


at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
at 
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1148)
at org.apache.tools.ant.helper.ProjectHelperImpl.parse(ProjectHelperImpl.java)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java)
at org.apache.tools.ant.Main.runBuild(Main.java)
at org.apache.tools.ant.Main.start(Main.java)
at org.apache.tools.ant.Main.main(Main.java)
--- Nested Exception ---
java.lang.NoClassDefFoundError: junit/framework/TestListener
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:496)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:117)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$300(URLClassLoader.java:69)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:544)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:203)
at java.lang.ClassLoader.loadClass(ClassLoader.java:325)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:257)
at java.lang.Class.getConstructors0(Native Method)
at java.lang.Class.getDeclaredConstructors(Class.java:1109)
at org.apache.tools.ant.AntClassLoader.initializeClass(AntClassLoader.java)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java)
at 
org.apache.tools.ant.helper.ProjectHelperImpl$TaskHandler.finished(ProjectHelperImpl.java)


at 
org.apache.tools.ant.helper.ProjectHelperImpl$AbstractHandler.endElement(ProjectHelperImpl.java)


at 
org.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:552) 

at 
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:217)


at 
org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(XMLNamespaceBinder.java:594) 

at 
org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:817) 

at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:748)


at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1454)


at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)


at 
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:529)


at 
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:585)


at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
at 
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1148)
at org.apache.tools.ant.helper.ProjectHelperImpl.parse(ProjectHelperImpl.java)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java)
at org.apache.tools.ant.Main.runBuild(Main.java)
at org.apache.tools.ant.Main.start(Main.java)
at org.apache.tools.ant.Main.main(Main.java)
..........................
So it can't find junit/framework/TestListener. OK
But this IS on the classpath ??? How this i possible ?
So I removed taskdef and added this :
(to see does VM sees that classes with the same classpath : "<classpath 
refid="runtime-classpath"/>" )
...................
<target name="junit" description="Performs all JUnit regression tests." >
<!-- ADDED STUFF ********to see will the VM find the 
classes***************************************** -->
<java classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" 
fork="no">
<classpath refid="runtime-classpath"/>
</java>
<java classname="junit.framework.TestListener" fork="no">
<classpath refid="runtime-classpath"/>
</java>
<echo message="---------------------------" />
<!-- END ADDED STUFF ************************************************* -->
<junit printsummary="yes" fork="yes" dir="${build.test}/ojb">
<classpath refid="runtime-classpath"/>
<formatter type="plain" />
<test name="test.ojb.broker.AllTests"
haltonfailure="no"
outfile="target/test/tests-broker" >
</test>
<test name="test.ojb.odmg.AllTests"
haltonfailure="no"
outfile="target/test/tests-odmg" >
</test>
<test name="test.ojb.soda.AllTests"
haltonfailure="no"
outfile="target/test/tests-soda" >
</test>
</junit>
</target>
...........................

Then I got the printout :
.............................
junit:
[java] Running in same VM Executing 
'org.apache.tools.ant.taskdefs.optional.junit.JUnitTask' with
fileset: Setup scanner in dir C:\java\ojb9\lib with patternSet{ includes: 
[**/*.jar, **/*.zip] excludes: [] }
force loading org.apache.tools.ant.taskdefs.optional.junit.JUnitTask
Finding class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask
Finding class org.apache.tools.ant.Task
Finding class org.apache.tools.ant.ProjectComponent
Class java.lang.Object loaded from parent loader
Class org.apache.tools.ant.ProjectComponent loaded from ant loader
Class org.apache.tools.ant.Task loaded from ant loader
Class java.lang.Throwable loaded from parent loader
Class java.lang.RuntimeException loaded from parent loader
Finding class org.apache.tools.ant.types.EnumeratedAttribute
Class org.apache.tools.ant.types.EnumeratedAttribute loaded from ant loader
Finding class 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask$SummaryAttribute
Class 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask$SummaryAttribute 
loaded from ant loader
Finding class org.apache.tools.ant.taskdefs.optional.junit.BaseTest
Class org.apache.tools.ant.taskdefs.optional.junit.BaseTest loaded from ant 
loader
Finding class org.apache.tools.ant.taskdefs.optional.junit.JUnitTest
Class org.apache.tools.ant.taskdefs.optional.junit.JUnitTest loaded from 
ant loader
Finding class org.apache.tools.ant.BuildException
Class org.apache.tools.ant.BuildException loaded from ant loader
Class java.io.IOException loaded from parent loader
Class java.io.OutputStream loaded from parent loader
Class java.io.FileOutputStream loaded from parent loader
Finding class org.apache.tools.ant.taskdefs.ExecuteStreamHandler
Class org.apache.tools.ant.taskdefs.ExecuteStreamHandler loaded from ant 
loader
Class java.util.Hashtable loaded from parent loader
Class java.util.Properties loaded from parent loader
Class java.lang.ClassLoader loaded from parent loader
Finding class org.apache.tools.ant.AntClassLoader
Finding class org.apache.tools.ant.BuildListener
Class java.util.EventListener loaded from parent loader
Class org.apache.tools.ant.BuildListener loaded from ant loader
Class org.apache.tools.ant.AntClassLoader loaded from ant loader
Finding class 
org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter
Finding class junit.framework.TestListener
Class junit.framework.TestListener loaded from ant loader
Class org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter 
loaded from ant loader
Finding class org.apache.tools.ant.taskdefs.LogOutputStream
Class org.apache.tools.ant.taskdefs.LogOutputStream loaded from ant loader
Class java.lang.Exception loaded from parent loader
[java] java.lang.NoSuchMethodException: main
[java] Running in same VM Executing 'junit.framework.TestListener' with
fileset: Setup scanner in dir C:\java\ojb9\lib with patternSet{ includes: 
[**/*.jar, **/*.zip] excludes: [] }
force loading junit.framework.TestListener
Finding class junit.framework.TestListener
Class java.lang.Object loaded from parent loader
Class java.lang.Throwable loaded from parent loader
[java] java.lang.NoSuchMethodException: main
[echo] ---------------------------
BUILD FAILED
C:\java\ojb9\build.xml:417: Could not create task or type of type: junit.
Ant could not find the task or a class this task relies upon.
.............................

So the VM can find these classes , but the "junit" task still does'n work 
(without or with my try to make new taskdef for it).
SO PLEASE HELP, I AM GOING MAD !



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message