Running JUnit test causes Exception NoClassDefFoundError: junit/textui/ResultPrinter

Hi.

I'm having an issue with the latest stable release of Intellij.
I created a brand new maven project, included junit 4.12 as a test dependency but whenever I try to run a test, Intellij gives me the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/ResultPrinter      at java.lang.Class.forName0(Native Method)      at java.lang.Class.forName(Class.java:169)      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122) Caused by: java.lang.ClassNotFoundException: junit.textui.ResultPrinter      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)      at java.security.AccessController.doPrivileged(Native Method)      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)      ... 3 more


Any clues on what might cause this?

classpath here: /opt/apps/java/jdk1.6.0_26/bin/java -ea -Didea.launcher.port=7536 -Didea.launcher.bin.path=/home/marh20/app/intellij/intellij/bin -Didea.junit.sm_runner -Dfile.encoding=UTF-8 -classpath /home/marh20/app/intellij/intellij/lib/idea_rt.jar:/home/marh20/app/intellij/intellij/plugins/junit/lib/junit-rt.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/javaws.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/jce.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/plugin.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/charsets.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/deploy.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/management-agent.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/jsse.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/rt.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/resources.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/ext/dnsns.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/ext/sunpkcs11.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/ext/localedata.jar:/opt/apps/java/jdk1.6.0_26/jre/lib/ext/sunjce_provider.jar:/home/marh20/temp/TestJunitError/target/test-classes:/home/marh20/temp/TestJunitError/target/classes:/home/marh20/app/intellij/intellij/bin//home/marh20/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/marh20/app/intellij/intellij/bin//home/marh20/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 com.martin.test.TestTest,testGetS

3 comments
Comment actions Permalink

Hi Martin,

the paths looks strange: /home/marh20/app/intellij/intellij/bin//home/marh20/.m2/repository/junit/junit/4.12/junit-4.12.jar. Do you really have maven repository under IDEA's bin? Looks like it's wrong and have to be /home/marh20/.m2/repository/junit/junit/4.12/junit-4.12.jar. Could you please check?

Thanks,
Anna

0
Comment actions Permalink

That looks strange indeed, missed that one, looks like it could be the culprit.
I'll look first thing in the morning, not at work anymore.

0
Comment actions Permalink

That was indeed the issue.
In settings, IntelliJ had for some reason put the "local repository" to be /home/myusername/${HOME}/.m2/repository.
An override of that setting solved everything. Thanks for the help! =)

0

Please sign in to leave a comment.