finrod
finrod

Reputation: 571

Cannot run junit test in eclipse, ClassNotFoundException: org.eclipse.jdt.internal.junit.runner.RemoteTestRunner

When I try to run a junit test in eclipse on a project which is created with gradle I get the following error in the eclipse console

Error: Could not find or load main class org.eclipse.jdt.internal.junit.runner.RemoteTestRunner
Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.junit.runner.RemoteTestRunner

If I run the same test from the command line using

gradle test

it works fine.

Also I noticed that if I remove the following two dependencies:

testImplementation group: 'org.apache.tomee', name: 'openejb-cxf-rs', version: '8.0.0'
testImplementation group: 'org.apache.tomee', name: 'arquillian-tomee-embedded', version: '8.0.0'

the tests can be started in Eclipse. Obviously the tests fail at some point because of the missing dependencies.

Looks like this is some kind of weird conflict going on in Eclipse. Also it was working fine before the December update of Eclipse.

For completeness here the versions:

Today I also tried to install an older version of Eclipse (2019-09) and there with the same setup I could just run the tests.

Also I noticed the following. If I go to Run->Run Configurations, select my test runner and "Show command line" I notice that when things are not working the classpath is written in a file, whereas when it is working it is just written as command line arguments.

So the following is not working:

C:\Program Files\Java\jdk-11.0.4\bin\javaw.exe -ea -Dfile.encoding=Cp1252 "@C:\projects\provisioning-service\provisioning-service-resource\.temp-ExampleTest-classpath-arg-1578480407549.txt" org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 58388 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames com.xelion.provisioning.resource.ExampleTest

The following is

C:\Program Files\Java\jdk-11.0.4\bin\javaw.exe -ea -Dfile.encoding=Cp1252 -classpath "C:\projects\provisioning-service\provisioning-service-resource\target\bin;...manymorehere" org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 58412 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames com.xelion.provisioning.resource.ExampleTest

So the main difference seems to be that in the first case the classpath is evaluated from the file

C:\projects\provisioning-service\provisioning-service-resource\.temp-ExampleTest-classpath-arg-1578480407549.txt

and in the second case it is written out

-classpath "C:\projects\provisioning-service\provisioning-service-resource\target\bin;...

Upvotes: 2

Views: 8925

Answers (1)

finrod
finrod

Reputation: 571

Looks like an Eclipse bug, see here for details

https://bugs.eclipse.org/bugs/show_bug.cgi?id=558495

I added the following download side

https://download.eclipse.org/eclipse/updates/4.15-I-builds/I20200105-1800/

and updated "Eclipse Java Development Tools"

This solved the issue.

Upvotes: 3

Related Questions