ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AjayaSa...@TDWaterhouse.com
Subject RE: Unable to create junit task with ant 1.6.2 & junit3.8.1
Date Fri, 29 Oct 2004 15:41:14 GMT
Hi Jake,

It works fine with that approach. However, I am interested in creating a
junit task which is the clean way of doing this. I have followed the
suggestions for creating the task and I get this error "could n't findf
junit/framework/TestListener" although I have put the junit.jar in the
classpath. Why the loader fails to find the junit.jar which contains the
class?

Thanks,
Ajaya

-----Original Message-----
From: Jacob Kjome [mailto:hoju@visi.com] 
Sent: Friday, October 29, 2004 11:33 AM
To: Ant Users List
Subject: Re: Unable to create junit task with ant 1.6.2 & junit3.8.1


The JUnit task is located in ANT_HOME/lib.  If you want to use the JUnit
task
without putting junit.jar in ANT_HOME/lib or $user.home/.ant/lib, then
you'll
have to remove the junit task from ANT_HOME/lib and added manually to your
classpath just as you are manually adding junit.jar to your classpath.

Short answer, both the junit task and library need to be loaded in the same
classloader.  I always put jars required by tasks that come with Ant in
$user.home/.ant/lib so that when I upgrade Ant, I don't have to worry about
remembering not to delete extra jars added to ANT_HOME/lib.

Jake

Quoting AjayaSahoo@TDWaterhouse.com:

> Hi,
>
>
>
> I am using ant-1.6.2 & junit-3.8.1 and unable to create the junit task. I
> have looked into the archive and put both junit
>

<snip>

>
> I get the following error while creating the junit task:
>
>
>
> fileset: Setup scanner in dir C:\junitbook\repository\junit\jars with
> patternSet{ includes: [jun
>
> .8.1.jar] excludes: [] }
>
> fileset: Setup scanner in dir C:\apache-ant-1.6.2\lib with patternSet{
> includes: [ant-junit.jar]
>
> ludes: [] }
>
> Class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask loaded from
> parent loader (parentFi
>
>
>
>
>
> BUILD FAILED
>
> C:\junitbook\sampling\build.xml:59: taskdef A class needed by class
> org.apache.tools.ant.taskdef
>
> tional.junit.JUnitTask cannot be found: junit/framework/TestListener
>
>         at
> org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:487)
>
>         at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183)
>
>         at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
>
>         at org.apache.tools.ant.Task.perform(Task.java:364)
>
>         at org.apache.tools.ant.Target.execute(Target.java:341)
>
>         at org.apache.tools.ant.Target.performTasks(Target.java:369)
>
>         at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
>
>         at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
>
>         at org.apache.tools.ant.Main.runBuild(Main.java:673)
>
>         at org.apache.tools.ant.Main.startAnt(Main.java:188)
>
>         at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
>
>         at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
>
> --- Nested Exception ---
>
> java.lang.NoClassDefFoundError: junit/framework/TestListener
>
>         at java.lang.ClassLoader.defineClass0(Native Method)
>
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:703)
>
>         at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:133)
>
>         at java.net.URLClassLoader.defineClass(URLClassLoader.java:319)
>
>         at java.net.URLClassLoader.access$400(URLClassLoader.java:92)
>
>         at
java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:677)
>
>         at java.security.AccessController.doPrivileged(Native Method)
>
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:238)
>
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:516)
>
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:448)
>
>         at java.lang.Class.forName0(Native Method)
>
>         at java.lang.Class.forName(Class.java:220)
>
>         at
> org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:457)
>
>         at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183)
>
>         at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
>
>         at org.apache.tools.ant.Task.perform(Task.java:364)
>
>         at org.apache.tools.ant.Target.execute(Target.java:341)
>
>         at org.apache.tools.ant.Target.performTasks(Target.java:369)
>
>         at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
>
>         at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
>
>         at org.apache.tools.ant.Main.runBuild(Main.java:673)
>
>         at org.apache.tools.ant.Main.startAnt(Main.java:188)
>
>         at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
>
>         at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
>
> Thanks,
>
> Ajaya
>
>
>
>




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

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


Mime
View raw message