java-language-server
java-language-server copied to clipboard
Crashes on Arch Linux `NoSuchFileException: /usr/java`
On my machine, the folder /usr/java does not exist, and apparently that crashes the server (logs below).
I can see that in the JavaHomeHelper class, some folders are tested for the presence of 'bin/javac', however, the check crashes if the searched folder doesn't even exist (line).
I'm not sure what the purpose is of that rethrow, as in my opinion an exception in that place should just signal the checker to move on to another entry. Replacing the throw new RuntimeException(e) with continue fixes the problem.
Full log:
14:19:09.050 INFO LSP connect Reading messages from queue...
14:19:09.050 INFO LSP$1MessageReader run Placing incoming messages on queue...
14:19:09.199 SEVERE LSP connect Not a JSON Object: null
java.lang.IllegalStateException: Not a JSON Object: null
at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:91)
at org.javacs.JavaLanguageServer.didChangeConfiguration(JavaLanguageServer.java:217)
at org.javacs.lsp.LSP.connect(LSP.java:288)
at org.javacs.Main.main(Main.java:30)
14:19:09.415 INFO JavaLanguageServer lint Lint 1 files...
14:19:09.468 INFO ScanClassPath jdkTopLevelClasses Searching for top-level classes in the JDK
14:19:09.665 INFO ScanClassPath jdkTopLevelClasses Found 5794 classes in the java platform
Class path:
Doc path:
14:19:09.735 SEVERE Main main java.nio.file.NoSuchFileException: /usr/java
java.lang.RuntimeException: java.nio.file.NoSuchFileException: /usr/java
at org.javacs.JavaHomeHelper.check(JavaHomeHelper.java:84)
at org.javacs.JavaHomeHelper.linuxJavaHome(JavaHomeHelper.java:62)
at org.javacs.JavaHomeHelper.javaHome(JavaHomeHelper.java:30)
at org.javacs.Docs.findSrcZip(Docs.java:53)
at org.javacs.Docs.srcZip(Docs.java:39)
at org.javacs.Docs.<init>(Docs.java:18)
at org.javacs.JavaCompilerService.<init>(JavaCompilerService.java:37)
at org.javacs.JavaLanguageServer.createCompiler(JavaLanguageServer.java:112)
at org.javacs.JavaLanguageServer.compiler(JavaLanguageServer.java:39)
at org.javacs.JavaLanguageServer.lint(JavaLanguageServer.java:61)
at org.javacs.JavaLanguageServer.doAsyncWork(JavaLanguageServer.java:523)
at org.javacs.lsp.LSP.connect(LSP.java:247)
at org.javacs.Main.main(Main.java:30)
Caused by: java.nio.file.NoSuchFileException: /usr/java
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:432)
at java.base/java.nio.file.Files.newDirectoryStream(Files.java:475)
at java.base/java.nio.file.Files.list(Files.java:3762)
at org.javacs.JavaHomeHelper.check(JavaHomeHelper.java:81)
... 12 more
Process NOX (stepavo2/java-mode) stderr finished
Same issue on Ubuntu 18.04. Creating /usr/java and /opt/java allows the server to start, but that's a pretty ugly hack.
JavaHomeHelper is the key thing that needs to be fixed. It's job is to locate JAVA_HOME on any OS. A PR would be much appreciated!
https://github.com/georgewfraser/java-language-server/pull/148
I'm getting this problem also on debian. Wouldn't it be better to use bazel to get the JAVA_HOME in addition to just the dependencies for bazel projects?
It seems this issue can be closed now, as it was solved in https://github.com/georgewfraser/java-language-server/pull/148 On Arch just be sure to use the "java-language-server-git" package, as the release version is lagging behind and still does not include the fix.