ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emerson Cargnin - MSA" <emers...@sicredi.com.br>
Subject Re: JUnit and NoClassDefFoundError
Date Tue, 28 May 2002 22:49:48 GMT
Hi

I had a problem like that (classnotfoundexception) and solved putting >
  <pathelement location="${tests.dir}"/>  tag in the classpath tag, it
worked...

   <target name="test" depends="deploy,compilatests">
    <sleep seconds="10"/>
    <junit printsummary="true" fork="yes">
      <formatter type="plain" usefile="false"/>
      <test name = "br.com.sicredi.poc1.testes.Poc1Test"/>
   <classpath>
      <fileset dir="lib_build">
         <include name="**/*.jar" />
      </fileset>
  <pathelement location="${tests.dir}"/>
      </classpath>

    </junit>
   </target>


----- Original Message -----
From: "Tandon, Pankaj" <Pankaj.Tandon@crowncastle.com>
To: <ant-user@jakarta.apache.org>
Sent: Tuesday, May 28, 2002 6:52 PM
Subject: JUnit and NoClassDefFoundError


> Hi,
> I am trying to use the junit task and am having no luck :(
> I first got a NoClassDefFoundError on JUnitTestRunnerClass and then a
> NoClassDefFoundError  for the BuildException  class.
>
>
> I have tried the following:
> 1. Read the FAQ at
> http://jakarta.apache.org/ant/faq.html#delegating-classloader This is very
> insightfull and explained (or so I thought) the reasom I was getting the
> initial NoClassDefFoundError I was getting. This was when I had placed
> junit.jar AND jakarta-ant-1.3-optional.jar in my ANT_HOME/lib.
>
> 2. So I created a taskdef called ccJUnit and created a seperate folder for
> junit.jar and jakarta-ant-1.3-optional.jar and moved these files there
(from
> ANT_HOME/lib)
>
> My script looks like so:
>
>    <taskdef name="ccJUnit"
> classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" >
>      <classpath>
>        <pathelement
>
path="C:\ccic\zSiteInspections\src\external\ant\1.3\optional\jakarta-ant-1.3
> -optional.jar;C:\ccic\zSiteInspections\src\external\ant\1.3\optional\junit
.j
> ar" />
>      </classpath>
>    </taskdef>
>    <target name="junit"  >
>     <ccJUnit printsummary="true" fork="yes" haltonfailure="yes">
>       <formatter type="plain" usefile="false"/>
>       <test name ="com.crowncastle.sdm.common.xml.test.TestDownload"/>
>       <classpath>
>         <pathelement
>
path="${xalanClassPath};${commonClassPath};${log4jClassPath};${weblogicClass
>
Path};${strutsClassPath};C:\ccic\zSiteInspections\src\sdm\build\classes;C:\c
>
cic\zSiteInspections\src\external\ant\1.3\optional\jakarta-ant-1.3-optional.
> jar;C:\ccic\zSiteInspections\src\external\ant\1.3\optional\junit.jar" />
>       </classpath>
>     </ccJUnit>
>    </target>
>
> Note that I have optional.jar and junit.jar in BOTH the classpath
specified
> by the taskdef AND the one to run my test.
>
> Based on the FAQ, this shd have worked. But now my test failed and I got a
> BuildException (this is quite possibily because of an error in my
> application). But instead of getting a neat stack trace of my
BuildException
> , I get
>
> junit:
>   [ccJUnit] Running com.crowncastle.sdm.common.xml.test.TestDownload
>   [ccJUnit] java.lang.NoClassDefFoundError:
> org/apache/tools/ant/BuildException
>
>
> However the BuildException class lives in ant.jar. So the child
classloaer
> SHOULD have found it.
> Can someone wxplain why BuildException class is not being found, despite
> ant.jar existing in ANT_HOME/lib
>
> 3. So.. getting desperate (and going by a suggestion on this list), I
turned
> fork="no"
> This resulted in  a ClassCastException.
>
> junit:
>   [ccJUnit] Running com.crowncastle.sdm.common.xml.test.TestDownload
>   [ccJUnit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
>   [ccJUnit] Testsuite: com.crowncastle.sdm.common.xml.test.TestDownload
>   [ccJUnit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
>   [ccJUnit]
>   [ccJUnit]     Caused an ERROR
>   [ccJUnit] junit.framework.TestSuite
>   [ccJUnit] java.lang.ClassCastException: junit.framework.TestSuite
>   [ccJUnit]     at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.
> <init>(JUnitTestRunner.java:178)
>   [ccJUnit]     at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execut
> eInVM(JUnitTask.java:387)
>   [ccJUnit]     at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execut
> e(JUnitTask.java:283)
>   [ccJUnit]     at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execut
> e(JUnitTask.java:263)
>   [ccJUnit]     at org.apache.tools.ant.Target.execute(Target.java:153)
>   [ccJUnit]     at
org.apache.tools.ant.Project.runTarget(Project.java:898)
>   [ccJUnit]     at
> org.apache.tools.ant.Project.executeTarget(Project.java:536)
>   [ccJUnit]     at
> org.apache.tools.ant.Project.executeTargets(Project.java:510)
>
>   [ccJUnit]     at org.apache.tools.ant.Main.runBuild(Main.java:421)
>   [ccJUnit]     at org.apache.tools.ant.Main.main(Main.java:149)
>   [ccJUnit]
>
> BUILD FAILED
>
> C:\ccic\zSiteInspections\src\sdm\build.xml:322: Test
> com.crowncastle.sdm.common.
> xml.test.TestDownload failed
>
>
>
> 4. So lastly I tried turning the verbose flag on... not much help there.
>
>
> I suspect, I have to leave the fork="yes" attrib on as in point 2 above. I
> amnot sure why ANT cannot find the BuildExeption tho'
>
> Any pointers wil be greatly appreciated.
>
> TIA
> Pankaj
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


--
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