wood burning stoves 2.0*
The moose likes Java in General and the fly likes java.lang.NoClassDefFoundError: junit.framework.Test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.lang.NoClassDefFoundError: junit.framework.Test" Watch "java.lang.NoClassDefFoundError: junit.framework.Test" New topic
Author

java.lang.NoClassDefFoundError: junit.framework.Test

Deepti Bhatia
Greenhorn

Joined: Oct 19, 2006
Posts: 25
Hi,

I am getting the below error when the junit test class is run. The junit jar has been configured on the classpath.

java.lang.NoClassDefFoundError: junit.framework.Test
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:59)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:120)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:127)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadTestLoaderClass(RemoteTestRunner.java:324)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:314)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:309)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:287)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:210)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:195)
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Please tell the details. How you run the program, from command line/build script ? and which command(s) used ? Where is your source/compiled package hierarchy located ? Show us the classpath entry ?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Deepti Bhatia
Greenhorn

Joined: Oct 19, 2006
Posts: 25
Program run with eclipse Run -> Junit.

Source - >CSRT-presentation/src/main/java
- >CSRT-presentation/src/test/java
Classes - > CSRT-presentation/target/classes

Classpath entry - > <classpathentry kind="lib" path="C:/Documents and Settings/user/Desktop/LIB/junit-3.8.1.jar"/>
Alan Hampson
Ranch Hand

Joined: Apr 10, 2009
Posts: 31
Check your Project Properties->Java Build Path->Libraries (tab). JUnit should be there although this usually will show up in the build.

Check you Project's Run Configurations->JUnit->Classpath (tab). JUnit should be under User Entries for your project.

BTW, Eclipse has it's own junit.jar (under eclipse/plugins), so you may want to use that for consistency.

Hope this helps,
alan
Deepti Bhatia
Greenhorn

Joined: Oct 19, 2006
Posts: 25
Added junit jar in User Entries as suggested. It is not able to load the test class now.

Class not found com.pck.TestClass
java.lang.ClassNotFoundException: com.pck.TestClass
at java.net.URLClassLoader.findClass(URLClassLoader.java:492)
at java.lang.ClassLoader.loadClass(ClassLoader.java:606)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:327)
at java.lang.ClassLoader.loadClass(ClassLoader.java:563)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:425)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.lang.NoClassDefFoundError: junit.framework.Test
 
Similar Threads
Using easy mocks : getting NoClassDefFoundError
Application error when running an Junit test case
URLClassLoader.java- Class not found Exception
getting runtime error with junit test case : no classdeffound
NoClassDefFoundError exception in InitialContext()