You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2013/04/13 00:36:20 UTC

[Bug 54835] New: Classpath use seems to be broken in junit ant task?

https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

            Bug ID: 54835
           Summary: Classpath use seems to be broken in junit ant task?
           Product: Ant
           Version: 1.9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Optional Tasks
          Assignee: notifications@ant.apache.org
          Reporter: andrew@acooke.org
    Classification: Unclassified

I don't fully understand the history of classpath loading, but at
http://ant.apache.org/manual/Tasks/junit.html item 5 says "Leave ant-junit.jar
in its default location in ANT_HOME/lib but include junit.jar in the
<classpath> passed to <junit>. (since Ant 1.7)" - that appears not to work.

I have a detailed SO question at
http://stackoverflow.com/questions/15979391/class-not-found-with-ant-ivy-and-junit-error-in-build-xml
but to reproduce simply:

hg clone ssh://hg@bitbucket.org/isti/java-example
cd java-example
ant test

and you should see:

BUILD FAILED
/home/andrew/project/guice/hg/build.xml:33: java.lang.NoClassDefFoundError:
junit/framework/TestListener
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
...
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.lang.ClassNotFoundException: junit.framework.TestListener
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
...

(the above project uses ant; alternatively copy junit-4.8.2.jar to ./lib and
delete the ivy task from the build.xml).

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

ashish.soni@siemens.com <as...@siemens.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ashish.soni@siemens.com

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

--- Comment #3 from andrew cooke <an...@acooke.org> ---
I am now working on this repo.  The example referred to above is tagged as
"classpath problem" so to check out please do:

hg clone ssh://hg@bitbucket.org/isti/java-example
cd java-example
hg update -r "classpath problem"

Thanks, Andrew

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

--- Comment #14 from Nico Kruber <ni...@gmail.com> ---
actually, only providing ant-junit-1.9.0.jar in the test-lib folder is
sufficient to make it work again

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

Nico Kruber <ni...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nico.kruber@gmail.com

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

--- Comment #6 from Michael Clarke <mi...@gmail.com> ---
It looks like the class search is being delegated to the System's classloader
rather than being handled by the Ant Classloader (the system Classloader has no
knoweldge of JUnit since JUnit isn't on the core Ant Classpath, but is added to
the JUnit task by Ivy). Given some JUnit classes must have already been loaded
to have reached this point, the Ant Classloader can see the JUnit jars loaded
by Ivy, but the Split Classloader seems to be delegating incorrectly when
trying to load classes used by the JUnit Runner.

I suspect the list of 'split classes' in JUnitTask needs expanded to include
the classes added for the @Ignore changes introduced in Ant 1.9.0. I'll do a
bit more investigation on this issue to see if there are any other issues
caused by JUnit being inherited from an external source rather than being in
the ANTLIB directory whilst I fix this issue.

In the meantime, copying your JUnit JAR into your ANTLIB directory will allow
Ant to pickup the dependent classes required to launch the JUnit task if you
want to continue using Ant 1.9.0.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

Michael Clarke <mi...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|PC                          |All
   Target Milestone|---                         |1.9.1
                 OS|Linux                       |All

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

George <gj...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

George <gj...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #12 from George <gj...@yahoo.com> ---
Totally my bad.. I didn't see that this particular case I was fiddling with
extended junit3 TestCase.  Time to go shave heads.. mine and someone else's.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

Jesse Glick <jg...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jglick@apache.org

--- Comment #9 from Jesse Glick <jg...@apache.org> ---
Looks like this bug only affected calls to <junit> with fork="false" (the
unfortunate default), which should be considered deprecated as far as I am
concerned; with fork="true" it is reported to work in 1.9.0.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

Michael Clarke <mi...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Michael Clarke <mi...@gmail.com> ---
Fixed under SVN revision 1470668.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

--- Comment #1 from andrew cooke <an...@acooke.org> ---
Correction: "(the above project uses ant; alternatively" should be "(the above
project uses IVY; alternatively..."

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

Nico Kruber <ni...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #13 from Nico Kruber <ni...@gmail.com> ---
It looks like this fix actually broke JUnit4 for me. Everything up to (and
including) 1.9.0 works fine, 1.9.1-1.9.3 do not.
I created a fairly minimal test case at my git repository
https://github.com/NicoK/ant-1.9-junit

git clone https://github.com/NicoK/ant-1.9-junit.git
cd ant-1.9-junit.git
ant test

(I tested 1.9.0 by adding it to the test-lib directory and setting
includeantruntime="false" for the JUnit task in the ant build file)

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

--- Comment #10 from George <gj...@yahoo.com> ---
I'm still seeing this problem as of ant 1.9.1

I have a unit test flagged as such:

@RunWith(SpringJUnit4ClassRunner.class)

and an ant test target that contains

 <junit printsummary="yes" haltonfailure="yes" fork="true"  forkmode="once"
tempdir="${report.tests.dir}">
   <classpath refid="test.classpath.run"/>

   <formatter type="plain"/>

   <batchtest fork="yes" todir="${report.tests.dir}">
     <fileset dir="${src.tests.dir}">
       <include name="**/*IntegrationTestCase*.java"/>
     </fileset>
   </batchtest>

</junit>

my classpath is built via ivy.

The ant test run does not honor the 'RunsWith' annotation.  A stack trace
demonstrates this.  Running in eclipse works fine.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

--- Comment #7 from andrew cooke <an...@acooke.org> ---
Thanks.  I've switched back to 1.8 for now (I know that I can fix it by moving
jars, but the motivation is to have the build bootstrap itself completely to
simplify the process for other users).

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

--- Comment #4 from andrew cooke <an...@acooke.org> ---
Things are clearer now.  The following:

hg clone ssh://hg@bitbucket.org/isti/java-example
cd java-example
hg update -r "works with 1.8.4"
ant bootstrap test

works (gives an error because my test is missing a constructor) with Ant 1.8.4
but fails with Ant 1.9.0.

This is with a "virgin" Ant install.  The "bootstrap" copies the Ivy jar into
~/.ant/lib and then "test" downloads Junit jar to the local lib directory.

With Ant 1.8.4, having the Junit jar in the classpath for the junit task works
just fine.  As documented at http://ant.apache.org/manual/Tasks/junit.html
(item 5).  But with Ant 1.9.0 this code DOES NOT WORK.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

--- Comment #2 from andrew cooke <an...@acooke.org> ---
I'm not sure this is a good bug report, sorry - the details are mainly at the
SO question.  If you'd prefer me to repeat them here I can do so.  Basically -
I provide a classpath to the junit task, but it still gives a class not found
error.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

Jesse Glick <jg...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression

--- Comment #5 from Jesse Glick <jg...@apache.org> ---
Michael?

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

andrew cooke <an...@acooke.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrew@acooke.org

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 54835] Classpath use seems to be broken in junit ant task?

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54835

--- Comment #11 from George <gj...@yahoo.com> ---
Actually, I haven't the vaguest idea.  I've tried using ant 1.8.4 with and
without the junit4 jar in the lib directory, as well as ant 1.9.1.  I'm
flumoxed.  This may very well be my stupidity someplace.

-- 
You are receiving this mail because:
You are the assignee for the bug.