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 2008/04/04 16:43:51 UTC

DO NOT REPLY [Bug 44756] New: Can' t get a class name or stack trace for NoClassDefFoundError

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

           Summary: Can't get a class name or stack trace  for
                    NoClassDefFoundError
           Product: Ant
           Version: 1.6.5
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: Core
        AssignedTo: notifications@ant.apache.org
        ReportedBy: kevin.gilpin@alum.mit.edu


Created an attachment (id=21782)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21782)
Ant's -v log of the junit task, also the contents of my ant/lib

I am running the JUnit ant task. The output of the task is:

    [junit] Exception in thread "main" java.lang.NoClassDefFoundError: 
    [junit] Tests FAILED

I've tried everything I can think of to get the class name or a stack trace
without success, including:

* -v and -debug flags
* loading up a console and looking in the ClassLoader for duplicates of Ant
classes (i'm not using anything suspect like weblogic.jar)
* running Ant in a debugger. I can't set a breakpoint for NoClassDefFoundError
because it's occurring in a forked process

I'm at a loss to figure out what's going on. There may be a problem with my
classpath but Ant doesn't give me enough information to figure out what it
might be.

Same problem occurs with Ant 1.6.2.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 44756] Can' t get a class name or stack trace for NoClassDefFoundError

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


Colm Smyth <la...@gmail.com> changed:

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




--- Comment #1 from Colm Smyth <la...@gmail.com>  2008-05-13 17:11:25 PST ---
I agree it's not very obvious how to achieve this, but if you add an element
<formatter type="plain">
within your <junit> element, a text file will be created with the stack trace
of your test case.

I wrote a basic test class XXXTest (no package) that referred to a missing
class; the output went to a file TEST-XXXTest.txt as follows:

Testsuite: XXXTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
------------- Standard Error -----------------
This message went to syserr
------------- ---------------- ---------------

        Caused an ERROR
YYYTest
java.lang.NoClassDefFoundError: YYYTest
        at XXXTest.<clinit>(XXXTest.java:17)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
Caused by: java.lang.ClassNotFoundException: YYYTest
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)


Note the NoClassDefFoundError. If however you run it on a class that doesn't
exist (e.g. XXXTest1), you get a ClassNotFoundException:

Testsuite: XXXTest1
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

        Caused an ERROR
XXXTest1
java.lang.ClassNotFoundException: XXXTest1
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)

I hope this helps.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 44756] Can' t get a class name or stack trace for NoClassDefFoundError

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


Kevin Gilpin <ke...@alum.mit.edu> changed:

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




--- Comment #2 from Kevin Gilpin <ke...@alum.mit.edu>  2008-07-21 13:14:59 PST ---
The problem is not when the test class itself does not exist, it appears to be
when some class referenced by the test class does not exist. These tests work
fine in my IDE. I can't figure out how to get Ant to tell me what class it
can't find, nor how to attach a debugger to a running Ant JUnitTestRunner.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.