Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Problem With JUnit In Galileo (Cannot resolve imports and annotations even though JUnit 4 on build path.)
Problem With JUnit In Galileo [message #484507] Mon, 07 September 2009 15:59 Go to previous message
Eclipse UserFriend
I'm having problems getting JUnit tests to work in Galileo (Eclipse Java EE for Web Developers build 20090621-0832). I've installed it in /opt/eclipse/ to be shared. I created a JPA project and wrote a very simple JUnit 4 test:

import static org.junit.Assert.*;
import org.junit.Test;

public class FooTest {
   @Test
   public void testFoo() {
      assertTrue(false);
   }
}


Eclipse cannot resolve the imports, @Test annotation, and the assertTrue method even though the project has the JUnit 4 library on the build path. If I remove the JUnit 4 library from the build path and try to re-add it, the add-library dialog shows "The selected JUnit version is not available" and "Not found" for both current location and source location which prevents me from adding it. If I manually add the junit.jar file to the build path then the imports, etc are resolved but trying to run the JUnit test in Eclipse results in a NoClassDefFoundError for org.hamcrest.SelfDescribing:

java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:637)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
	at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
	at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:29)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:40)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:30)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
	... 25 more


Any ideas?

BTW, I tried searching for this in the forums but search seems to be broken or it didn't return any results.

[Updated on: Mon, 07 September 2009 16:01] by Moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:How to get hotswap with Eclipse 3.5 and WebLogic 10.1?
Next Topic:Issue Setting Classpath Variables
Goto Forum:
  


Current Time: Sat Oct 11 04:24:07 EDT 2025

Powered by FUDForum. Page generated in 0.04757 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top