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

java.lang.ClassNotFoundException: scala.meta.metals.Main #366

Closed
tym-network opened this issue Jul 27, 2020 · 6 comments · Fixed by scalameta/metals-languageclient#164
Closed
Labels
bug Something isn't working

Comments

@tym-network
Copy link

Describe the bug

Metals server crashes when opening a Scala project.

To Reproduce
Steps to reproduce the behavior:

  1. Open a Scala project in VSCode
  2. In the Notification drawer, it says "Starting Metals server..."
  3. After a few seconds, the following error in displayed in the notification server: "The Metals server crashed 5 times in the last 3 minutes. The server will not be restarted."

Expected behavior

The Metals server starts properly.

Screenshots
Metals1
Metals2

Installation:

  • Operating system: Windows 10
  • VSCode version: 1.47.2
  • VSCode extension version: 1.9.2
  • Metals version: 0.9.2

Additional context

Here is the content of the log file located in AppData/Roaming/Code/logs/xxx/exthost1/output_logging_xxx:

Java home: C:\Program Files\Java\jdk-11.0.8
Error: Could not find or load main class scala.meta.metals.Main
Caused by: java.lang.ClassNotFoundException: scala.meta.metals.Main
[Info  - 22:51:16] Connection to server got closed. Server will restart.
Error: Could not find or load main class scala.meta.metals.Main
Caused by: java.lang.ClassNotFoundException: scala.meta.metals.Main
[Info  - 22:51:17] Connection to server got closed. Server will restart.
Error: Could not find or load main class scala.meta.metals.Main
Caused by: java.lang.ClassNotFoundException: scala.meta.metals.Main
[Info  - 22:51:17] Connection to server got closed. Server will restart.
Error: Could not find or load main class scala.meta.metals.Main
Caused by: java.lang.ClassNotFoundException: scala.meta.metals.Main
[Info  - 22:51:17] Connection to server got closed. Server will restart.
Error: Could not find or load main class scala.meta.metals.Main
Caused by: java.lang.ClassNotFoundException: scala.meta.metals.Main
[Error - 22:51:17] Connection to server got closed. Server will not be restarted.

I installed Java 11 and specified the path in VSCode settings metals.javaHome.
I also installed Scala using the .exe

Could the error be because I have an accent in my first name (which is also in the name of my home folder)?

Search terms
metals server crashed ClassNotFoundException main

@tgodzik
Copy link
Contributor

tgodzik commented Jul 27, 2020

Thanks for reporting! The issue might be coming from having the additional accent, though I hoped this was fixed recently. Especially that it seems to be running Java properly. I will try to reproduce it locally.

Did you try reloading the window maybe? I've seen situation where the Main class of the server was not detected at first, however I have no idea why.

@tgodzik tgodzik added the bug Something isn't working label Jul 27, 2020
@tym-network
Copy link
Author

Thanks for your blazing fast answer!

Unfortunately, I have the error every time I open VSCode... I've never been able to make it work. Reloading the window or re-opening VSCode doesn't solve the issue.

@tgodzik
Copy link
Contributor

tgodzik commented Jul 28, 2020

Ok, I can reproduce the issue on Windows. It doesn't seem to cope well with accents.

@vikas-saxena02
Copy link

Hi guys, I am getting the same error on Metals 1.2, can you please elaborate on how to bypass it. I do not have accents in username on my system which is RHEL 7.9 running VScode 1.85.2

@divijan
Copy link

divijan commented May 29, 2024

@vikas-saxena02 any luck with your problem? I'm having the same thing on Windows 10 with cyrillic username

@vikas-saxena02
Copy link

@divijan Metals does require a lot of dependencies available to it in order to start which need to come from either mavencentral or if you are in a an airgap system like me from your local package repository such as artificatory or Nexus.
If its the later, you will need to go to settings -> Metals and point the following properties to your repository.

  • Coursier Mirror
  • Custom Repositories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants