Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassNotFoundException #918

Closed
lovekill opened this issue Jan 9, 2020 · 13 comments
Closed

ClassNotFoundException #918

lovekill opened this issue Jan 9, 2020 · 13 comments

Comments

@lovekill
Copy link

lovekill commented Jan 9, 2020

steps:

  1. delete bin dir
  2. click run test
    then an ClassNotFoundException will appear in debug console
@lovekill
Copy link
Author

lovekill commented Jan 9, 2020

The exception stack:
Class not found cn.anjiu.bee.OrderWorkDaoTest
java.lang.ClassNotFoundException: cn.anjiu.bee.OrderWorkDaoTest
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
URLClassLoader.java:381
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
ClassLoader.java:424
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
ClassLoader.java:357
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:780)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:503)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:526)

@jdneo
Copy link
Member

jdneo commented Jan 9, 2020

@lovekill, please provide the following information if it's possible

what kind of project are you using? Maven/Gradle/Eclipse?
What's your VS Code and Test Runner extension version?

Please share a sample project if it's possible, which would be helpful to diagnostic.

@lovekill
Copy link
Author

lovekill commented Jan 9, 2020

gradle project .
when i clean the java language server workspace this problem disappear !

@jdneo
Copy link
Member

jdneo commented Jan 9, 2020

Good to know problem solved!

@ETLJ
Copy link

ETLJ commented Aug 30, 2020

gradle project .
when i clean the java language server workspace this problem disappear !

I had the same issue and this worked for me. Thanks!

@pkondekar29
Copy link

pkondekar29 commented Oct 9, 2020

I tried to clean the JAVA language server and it did not work for me. Can anyone please tell what is the workaround for this issue?

My team is still at JAVA 8 hence I am not sure if I will be able to upgrade to the latest version!

Could you please let me know the extension version in which this is fixed?

Exception has occurred: java.lang.ClassNotFoundException
"java.lang.ClassNotFoundException: org.eclipse.jdt.internal.junit.runner.RemoteTestRunner"

My JAVA Test runner is at version - 0.22.0

@jdneo
Copy link
Member

jdneo commented Oct 9, 2020

@pkondekar29 JDK 11 is only required to launch the Java language server, you can still use JDK 1.8 to build your project.

What if trying the following setting?

    "java.home": "C:\\AdoptOpenJDK\\jdk-11.0.8.10-hotspot",
    "java.configuration.runtimes": [
        {
          "default": true,
          "name": "JavaSE-1.8",
          "path": "C:\\Java\\openjdk8u181-b13",
        }
    ],

@TeaTotalin
Copy link

One thing that worked to clear this problem up for me was to build the project on the command line (without running tests). After that the tests run just fine via the VS Code GUI. I'm using Maven, so in the project folder I run:

mvn clean install -DskipTests

After that the tests work.

@jdneo
Copy link
Member

jdneo commented Nov 20, 2022

@TeaTotalin Sounds like the project could not be built successfully from the extension, is it possible to provide a sample project?

@AlexanderTirik
Copy link

The extension worked fine for a while. But now the tests have stopped building all classes.

mvn clean install -DskipTests only works for unit tests.
Integration tests throw the error: java.lang.IllegalStateException: Unable to read meta-data for class ...
Unfortunately, I can't provide an example project.

One thing that worked to clear this problem up for me was to build the project on the command line (without running tests). After that the tests run just fine via the VS Code GUI. I'm using Maven, so in the project folder I run:

mvn clean install -DskipTests

After that the tests work.

@jdneo
Copy link
Member

jdneo commented Jan 20, 2023

That's because the build job is done by command line, which could not be done correctly by the extension.

It would be helpful for us to understand the problem if a sampe project can be provided.

@AlexanderTirik
Copy link

Update to my problem.
The problem was not in the test runner extension. The new maven extension broke the build process. Downgrading to the previous version helped fix it.

The extension worked fine for a while. But now the tests have stopped building all classes.

mvn clean install -DskipTests only works for unit tests. Integration tests throw the error: java.lang.IllegalStateException: Unable to read meta-data for class ... Unfortunately, I can't provide an example project.

One thing that worked to clear this problem up for me was to build the project on the command line (without running tests). After that the tests run just fine via the VS Code GUI. I'm using Maven, so in the project folder I run:
mvn clean install -DskipTests
After that the tests work.

@jdneo
Copy link
Member

jdneo commented Jan 28, 2023

@AlexanderTirik, do you mean the execution results of the maven goal via the maven extension are different?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants