java.lang.ClassNotFoundException: com.intellij.rt.execution.junit.JUnitStarter

Answered

Hi, I'm using the latest beta version of intellij (Build 90.193) and I'm trying to run my unit tests, but I can't do it because I get this error:

Exception in thread "main" java.lang.ClassNotFoundException: com.intellij.rt.execution.junit.JUnitStarter
     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:307)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
     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:102)


I added the reference to the idea_rt.jar in my classpath but the error still appears and make sense because the class JUnitStarter is not longer on this jar, so the question is, why is not longuer in the jar?, there is another libs I should/can use in order to find that "old" JUnitStarter?, please help me, I'm runing my test using ant, it works, but I want to do it with IntelliJ.
By the way, I'm using JUnit 4.4 and jdk 1.6.0.16.

Thanks in advance.

9 comments
Comment actions Permalink

Hello Jonathan,

you do not need to add JUnitStarter into your classpath (it is a class from
IDEA runtime) and it is now located in the other jar indeed.

Could you please send me classpath of your tests which is available in console
on the right of the tests tree?

Thank you
-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Hi, I'm using the latest beta version of intellij (Build 90.193) and
I'm trying to run my unit tests, but I can't do it because I get this
error:

Exception in thread "main"
java.lang.ClassNotFoundException:
com.intellij.rt.execution.junit.JUnitStarter

     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:307)

     at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

     at
java.lang.ClassLoader.loadClass(ClassLoader.java:252)

     at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

     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:102){c
ode}

I added the reference to the idea_rt.jar in my classpath but the error
still appears and make sense because the class JUnitStarter is not
longer on this jar, so the question is, why is not longuer in the
jar?, there is another libs I should/can use in order to find that
"old" JUnitStarter?, please help me, I'm runing my test using ant, it
works, but I want to do it with IntelliJ.

By the way, I'm using JUnit 4.4 and jdk 1.6.0.16.

Thanks in advance.

---
Original message URL:
http://www.jetbrains.net/devnet/message/5250616#5250616



0
Comment actions Permalink

Thanks for the quick asnwer Anna, this is my classpath (The one that is displayed in console)

/usr/lib/jvm/java-6-sun-1.6.0.16/bin/java -classpath /home/jonathan/Proyectos/InMonteverde/repository/trunk/output/admin/web/WEB-INF:/home/jonathan/Proyectos/InMonteverde/repository/trunk/output/admin/web/WEB-INF/lib/incontact-common-core.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/output/admin/web/WEB-INF/lib/incontact-common-web.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/output/admin/web/WEB-INF/lib/incontact-common-props.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/output/admin/web/WEB-INF/lib/incontact-common-test.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/output/admin/web/WEB-INF/lib/incontact-admin-test.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/output/admin/web/WEB-INF/lib/incontact-admin-core.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/output/admin/web/WEB-INF/lib/incontact-admin-props.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/junit-4.4.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/log4j-1.2.15.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/antlr.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/asm.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/cglib.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/commons-codec.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/commons-collections.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/commons-fileupload.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/commons-io.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/commons-lang.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/commons-logging.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/dom4j.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/ehcache-core-1.7.0.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/ejb3-persistence.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/hibernate-annotations.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/hibernate.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/javaee.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/json.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/jstl.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/jta-1.1.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/mail.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/mysql-5.0.8.jdbc.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/sitemesh-2.4.1.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring-beans.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring-core.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring-security-acl-2.0.4.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring-security-core-2.0.4.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring-security-core-tiger-2.0.4.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring-security-taglibs-2.0.4.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring-test.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring-webmvc.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/standard.jar:/usr/lib/jvm/java-6-sun/lib/tools.jar:/home/jonathan/bin/idea-IU-90.193/lib/ant/lib/ant-launcher.jar:/home/jonathan/bin/idea-IU-90.193/lib/ant/lib/ant.jar:/home/jonathan/bin/idea-IU-90.193/lib/ant/lib/ant-junit.jar:/home/jonathan/bin/idea-IU-90.193/lib/idea_rt.jar -Didea.launcher.port=7532 -Didea.launcher.bin.path=/home/jonathan/bin/idea-IU-90.193/bin -Dfile.encoding=UTF-8 com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.incontact.common.test.client.CompanyTest


The reason I added the idea_rt.jar to my classpath was because whitout it I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/rt/execution/application/AppMain
Caused by: java.lang.ClassNotFoundException: com.intellij.rt.execution.application.AppMain
     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:307)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: com.intellij.rt.execution.application.AppMain.  Program will exit.



Thank you Anna!, please let me know if you need more information.

--
Jonathan Gamba

0
Comment actions Permalink

Hello Jonathan,

How do you start your tests? Why do you have ant jars in classpath?

JUnit adds our runtime classes to your classpath and I do not see that jars
in yours.


Thank you
-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Thanks for the quick asnwer Anna, this is my classpath (The one that
is displayed in console)

 /home/jonathan/Proyectos/InMonteverde/repository/trunk/output/admin/we
> b/WEB-INF:/home/jonathan/Proyectos/InMonteverde/repository/trunk/outpu
> t/admin/web/WEB-INF/lib/incontact-common-core.jar:/home/jonathan/Proye
> ctos/InMonteverde/repository/trunk/output/admin/web/WEB-INF/lib/incont
> act-common-web.jar:/home/jonathan/Proyectos/InMonteverde/repository/tr
> unk/output/admin/web/WEB-INF/lib/incontact-common-props.jar:/home/jona
> than/Proyectos/InMonteverde/repository/trunk/output/admin/web/WEB-INF/
> lib/incontact-common-test.jar:/home/jonathan/Proyectos/InMonteverde/re
> pository/trunk/output/admin/web/WEB-INF/lib/incontact-admin-test.jar:/
> home/jonathan/Proyectos/InMonteverde/repository/trunk/output/admin/web
> /WEB-INF/lib/incontact-admin-core.jar:/home/jonathan/Proyectos/InMonte
> verde/repository/trunk/output/admin/web/WEB-INF/lib/incontact-admin-pr
> ops.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/
> lib/junit-4.4.jar:/home/jonathan/Proyectos/InMonteverde/repository/tru
> nk/common/lib/log4j-1.2.15.jar:/home/jonathan/Proyectos/InMonteverde/r
> epository/trunk/common/lib/antlr.jar:/home/jonathan/Proyectos/InMontev
> erde/repository/trunk/common/lib/asm.jar:/home/jonathan/Proyectos/InMo
> nteverde/repository/trunk/common/lib/cglib.jar:/home/jonathan/Proyecto
> s/InMonteverde/repository/trunk/common/lib/commons-codec.jar:/home/jon
> athan/Proyectos/InMonteverde/repository/trunk/common/lib/commons-colle
> ctions.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/comm
> on/lib/commons-fileupload.jar:/home/jonathan/Proyectos/InMonteverde/re
> pository/trunk/common/lib/commons-io.jar:/home/jonathan/Proyectos/InMo
> nteverde/repository/trunk/common/lib/commons-lang.jar:/home/jonathan/P
> royectos/InMonteverde/repository/trunk/common/lib/commons-logging.jar:
> /home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/dom4
> j.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/li
> b/ehcache-core-1.7.0.jar:/home/jonathan/Proyectos/InMonteverde/reposit
> ory/trunk/common/lib/ejb3-persistence.jar:/home/jonathan/Proyectos/InM
> onteverde/repository/trunk/common/lib/hibernate-annotations.jar:/home/
> jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/hibernate.
> jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/
> javaee.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/comm
> on/lib/json.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk
> /common/lib/jstl.jar:/home/jonathan/Proyectos/InMonteverde/repository/
> trunk/common/lib/jta-1.1.jar:/home/jonathan/Proyectos/InMonteverde/rep
> ository/trunk/common/lib/mail.jar:/home/jonathan/Proyectos/InMonteverd
> e/repository/trunk/common/lib/mysql-5.0.8.jdbc.jar:/home/jonathan/Proy
> ectos/InMonteverde/repository/trunk/common/lib/sitemesh-2.4.1.jar:/hom
> e/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring-b
> eans.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common
> /lib/spring-core.jar:/home/jonathan/Proyectos/InMonteverde/repository/
> trunk/common/lib/spring-security-acl-2.0.4.jar:/home/jonathan/Proyecto
> s/InMonteverde/repository/trunk/common/lib/spring-security-core-2.0.4.
> jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/
> spring-security-core-tiger-2.0.4.jar:/home/jonathan/Proyectos/InMontev
> erde/repository/trunk/common/lib/spring-security-taglibs-2.0.4.jar:/ho
> me/jonathan/Proyectos/InMonteverde/repository/trunk/common/lib/spring-
> test.jar:/home/jonathan/Proyectos/InMonteverde/repository/trunk/common
> /lib/spring-webmvc.jar:/home/jonathan/Proyectos/InMonteverde/repositor
> y/trunk/common/lib/spring.jar:/home/jonathan/Proyectos/InMonteverde/re
> pository/trunk/common/lib/standard.jar:/usr/lib/jvm/java-6-sun/lib/too
> ls.jar:/home/jonathan/bin/idea-IU-90.193/lib/ant/lib/ant-launcher.jar:
> /home/jonathan/bin/idea-IU-90.193/lib/ant/lib/ant.jar:/home/jonathan/b
> in/idea-IU-90.193/lib/ant/lib/ant-junit.jar:/home/jonathan/bin/idea-IU
> -90.193/lib/idea_rt.jar -Didea.launcher.port=7532
> -Didea.launcher.bin.path=/home/jonathan/bin/idea-IU-90.193/bin
> -Dfile.encoding=UTF-8 com.intellij.rt.execution.application.AppMain
> com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4
> com.incontact.common.test.client.CompanyTest]]>


The reason I added the idea_rt.jar to my classpath was because whitout
it I get this error:

 java.lang.NoClassDefFoundError:
> com/intellij/rt/execution/application/AppMain
> 
> Caused by: java.lang.ClassNotFoundException:
> com.intellij.rt.execution.application.AppMain
> 
>      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:307)
> 
>      at
> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> 
>      at
> java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> 
>      at
> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
> 
> Could not find the main class:
> com.intellij.rt.execution.application.AppMain.  Program will
> exit.]]>


Thank you Anna!, please let me know if you need more information.

--
Jonathan Gamba
---
Original message URL:
http://www.jetbrains.net/devnet/message/5250737#5250737



0
Comment actions Permalink

Hello Anna, the reason why I have ant jars in my classpath is because I was testing to run the test cases using the classpath generated by ant, I made that test because the only way I found to run my tests was with ant, so, I give it a try to the ant generated classpath. But even with out ant jars the result is the same.

JUnit adds our runtime classes to your classpath and I do not see that jars in yours.


I think is because I use a custom output folder, I build the project using ant, not IntelliJ, so, I guess IntelliJ have problems with that.

But I was able to run my tests lastnight, I added to my classpath the idea_rt.jar and the junit-rt.jar and it works!, everything seems to be working fine, even the debug works, so I'm happy now.


So thanks a lot for your help Anna!, I really appreciate your interest.

--
Jonathan Gamba

0
Comment actions Permalink

Hello Jonathan,

it should work without all that stuff with jars. If you are interesting you
can send me your .iml/.ipr files to check your project configurations

Thank you
-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Hello Anna, the reason why I have ant jars in my classpath is because
I was testing to run the test cases using the classpath generated by
ant, I made that test because the only way I found to run my tests was
with ant, so, I give it a try to the ant generated classpath. But even
with out ant jars the result is the same.

JUnit adds our runtime
> classes to your classpath and I do not see that jars in yours.


I think is because I use a custom output folder, I build the project
using ant, not IntelliJ, so, I guess IntelliJ have problems with that.

But I was able to run my tests lastnight, I added to my classpath the
idea_rt.jar and the junit-rt.jar and it works!, everything seems to be
working fine, even the debug works, so I'm happy now.

So thanks a lot for your help Anna!, I really appreciate your
interest.

--
Jonathan Gamba
---
Original message URL:
http://www.jetbrains.net/devnet/message/5250847#5250847



0
Comment actions Permalink

Hello, Anna !

Now i reproduce that issue again.

Exception in thread "main" java.lang.ClassNotFoundException: com.intellij.rt.execution.junit.JUnitStarter
     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)
     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:108)


And after read that potic, problem already exists.(I have to junit and idea_rt jars on my classpath) Try to run in 10 and 12 IDEA. Junit 4.8

Thanks, Victor

0
Comment actions Permalink

Answer closed!

Thanks !

0
Comment actions Permalink

I have encountered the same problem using IntelliJ IDEA 2019.2.3 (Ultimate Edition) Build #IU-192.6817.14, built on September 23, 2019. On a hunch I unzipped idea_rt.jar and noticed that there is actually no JUnitStarter.class (com.intellij.rt.execution.junit.JUnitStarter) in this JAR. Which JAR should I be referencing?

1
Comment actions Permalink

Hello,

Is it possible to share sample project for investigation?

0

Please sign in to leave a comment.