-
Notifications
You must be signed in to change notification settings - Fork 406
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
How could I set javadoc_location to use local Java documentation. #2968
Comments
From https://github.com/eclipse-jdtls/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request : "settings": {
"java": {
...
...
"configuration": {
...
...
"runtimes": [
{
"name": "JavaSE-17",
"path": "/usr/lib/jvm/java-17-openjdk",
"default": true
}
}
}
} |
@rgrunber Thanks for your response! Unfortunately it didn't work for me. Looks like the class |
What client are you using to consume JDT-LS ? Any of the ones mentioned at https://github.com/eclipse-jdtls/eclipse.jdt.ls/#clients ? Where is the |
@rgrunber thanks for your patience. How did I encounter this: Upon investigating the error message, I discovered that the error is thrown from Specifically, in the method Given its name, |
Could you try to set
Could you access JDK 17 API? You can also try to install the JDK source. |
Thanks @snjeza . Yes, that's what I meant, but forgot to include the actual |
Init requst: {
"..." : "...",
"params":{
"..." : "...",
"initilizationOptions": {
"settings": {
"java": {
"configuration": {
"runtime": {
"name": "JavaSE-11",
"path": "/usr/lib/jvm/java-11-openjdk-amd64",
"javadoc": "file:///usr/share/doc/openjdk-11-doc/api/",
"default": true
}
}
}
}
}
}
} But it did not prevent me from getting error message (requesting docs from Internet) as: Nov 24, 2023, 7:30:06 AM docs.oracle.com\ndocs.oracle.com\nJava Model Exception: java.net.UnknownHostException: docs.oracle.com
at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:941)
at org.eclipse.jdt.internal.core.BinaryType.getJavadocContents(BinaryType.java:1090)
at org.eclipse.jdt.internal.core.BinaryType.getAttachedJavadoc(BinaryType.java:1047)
at org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:603)
at org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess2.getMarkdownContentReader(JavadocContentAccess2.java:2607)
at org.eclipse.jdt.ls.core.internal.HoverInfoProvider.computeJavadoc(HoverInfoProvider.java:311)
at org.eclipse.jdt.ls.core.internal.HoverInfoProvider.computeHover(HoverInfoProvider.java:150)
at org.eclipse.jdt.ls.core.internal.handlers.HoverHandler.computeHover(HoverHandler.java:57)
at org.eclipse.jdt.ls.core.internal.handlers.HoverHandler.hover(HoverHandler.java:43)
at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$7(JDTLanguageServer.java:580)
at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.net.UnknownHostException: docs.oracle.com
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:229)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:305)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:508)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:603)
at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)
at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:373)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:207)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:193)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1592)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:527)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:334)
at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:874)
... 17 more\nCaused by: java.net.UnknownHostException: docs.oracle.com
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:229)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:305)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:508)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:603)
at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)
at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:373)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:207)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:193)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1592)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:527)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:334)
at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:874)
at org.eclipse.jdt.internal.core.BinaryType.getJavadocContents(BinaryType.java:1090)
at org.eclipse.jdt.internal.core.BinaryType.getAttachedJavadoc(BinaryType.java:1047)
at org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:603)
at org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess2.getMarkdownContentReader(JavadocContentAccess2.java:2607)
at org.eclipse.jdt.ls.core.internal.HoverInfoProvider.computeJavadoc(HoverInfoProvider.java:311)
at org.eclipse.jdt.ls.core.internal.HoverInfoProvider.computeHover(HoverInfoProvider.java:150)
at org.eclipse.jdt.ls.core.internal.handlers.HoverHandler.computeHover(HoverHandler.java:57)
at org.eclipse.jdt.ls.core.internal.handlers.HoverHandler.hover(HoverHandler.java:43)
at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$7(JDTLanguageServer.java:580)
at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) |
I think the above error might be some DNS issue. It worked for me to have the javadoc downloaded from the remote location. The final URL requested is something like https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html (assuming you hover over the As for why it didn't respect your setting, the format you provided just needs to be adjusted as we only support
should become :
See Line 1186 in 99d7f7b
|
I fixed the {
"params":{
"initializationOptions":{
"settings": {
"java": {
"configuration": {
"runtime": [
{
"name": "JavaSE-17",
"path": "/usr/lib/jvm/java-17-openjdk-amd64",
"javadoc": "/usr/lib/jvm/java-17-openjdk-amd64/docs/api",
"default": true
}
]
}
}
}
}
}
} unfortunately, it still didn't work. Accroding to eclipse.jdt.ls/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/RuntimeEnvironment.java Line 151 in 99d7f7b
javadoc is invalid. However I did not get any error logs while setting a invalid value.
|
@armanim Could you show your .classpath file? |
Could you check your project root directory or |
There are two /jdt.ls.java.project/.classpath
/workspace-xxxx/.classpath
|
Could you try the following:
|
the workspace-xxx created again. And content of .classpath file is the same. |
What project are you using? Maven, Gradle, Eclipse? |
Single Java file in the workspace directory. |
Could you try to run
How did you set up monaco-languageclient? |
$ ls /usr/lib/jvm/java-17-openjdk-amd64/bin
jar java javadoc jcmd jdb jdeps jhsdb jinfo jmap jpackage jrunscript jstack jstatd rmiregistry
jarsigner javac javap jconsole jdeprscan jfr jimage jlink jmod jps jshell jstat keytool serialver
$ ls /usr/lib/jvm/java-17-openjdk-amd64/lib/src.zip
/usr/lib/jvm/java-17-openjdk-amd64/lib/src.zip and $ cat /usr/lib/jvm/java-17-openjdk-amd64/lib/src.zip
cat: /usr/lib/jvm/java-17-openjdk-amd64/lib/src.zip: No such file or directory This is how I setup monaco-languageclient monaco.editor.create(document.getElementById('container')!, {
model: monaco.editor.createModel(value, 'java', monaco.Uri.parse('file:///tmp/workspace/a.java')),
glyphMargin: true,
lightbulb: {
enabled: true
}
});
function createLanguageClient (transports: MessageTransports): MonacoLanguageClient {
return new MonacoLanguageClient({
name: 'Sample Language Client',
clientOptions: {
workspaceFolder: {
uri: monaco.Uri.parse('file:///tmp/workspace/'),
name: 'monaco-languageclient',
index: 0
},
documentSelector: ['java'],
initializationOptions: {
settings: {
java: {
configuration: {
runtime: [{
name: 'JavaSE-17',
path: '/usr/lib/jvm/java-17-openjdk-amd64',
javadoc: '/usr/lib/jvm/java-17-openjdk-amd64/docs/api',
default: true
}]
}
}
}
}
}
}); And Im using a relatively older version of it. the last commit is |
Could you try
You can also try to reinstall java-17-openjdk. |
$ ls -l /usr/lib/jvm/java-17-openjdk-amd64/lib/src.zip
lrwxrwxrwx 1 root root 24 Oct 31 23:39 /usr/lib/jvm/java-17-openjdk-amd64/lib/src.zip -> ../../openjdk-17/src.zip |
Could you try to run
|
JDT will give priority to Javadoc in the source even if a Javadoc URL is specified. |
What is the proper way to set
IntelliJ Idea uses the second notation when I pointed the JavaDoc of the JDK to the ZIP file in Project structure -> SDKs window. (I know that Idea doesn't use JDTLS; just FYI). |
I tried a zip file path (1) and that seems to work for me. I think URLs are also supported. |
@rgrunber I tried option 1 after deleting the JDK's src.zip and disconnecting from the Internet. The documentation tooltip in NeoVim did not show the documentation in that case, just the function signature. PFA the screenshot. (I tried option 2 also in the same scenario; that too didn't work.) @cypher256's comment mentions that the source always gets priority over the Javadoc. I think the Javadoc is not considered in any scenario by jdtls, if it is a ZIP file. |
Do you have a sample of what your configuration file looks like for the setting under neovim ? |
Here is my relevant Lua configuration file for NeoVim. I took it from AstroNvim. Jdtls version is 1.35.0. local home = os.getenv "HOME"
---@type LazySpec
return {
{
"mfussenegger/nvim-jdtls",
opts = {
settings = {
java = {
configuration = {
runtimes = {
{
name = "JavaSE-21",
path = home .. "/.sdkman/candidates/java/21.0.3-tem",
javadoc = "/opt/jdk-21.0.3_doc-all.zip",
default = true,
},
{
name = "JavaSE-17",
path = home .. "/.sdkman/candidates/java/17.0.11-tem",
},
{
name = "JavaSE-11",
path = home .. "/.sdkman/candidates/java/11.0.23-tem",
},
},
},
},
format = {
enabled = true,
settings = { -- you can use your preferred format style
url = "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml",
profile = "GoogleStyle",
},
},
},
},
},
} |
These are the NeoVim LSP logs.
|
You're absolutely right. I got the exact same stacktrace on VS Code. The relevant code attempts to fetch the sources in order to compute the javadoc, but obviously if you disable your network interface, this fails, Update: The error is logged at Line 125 in 3a8937a
so the error doesn't interrupt execution, and likely the problem has to do with what occurs after. I'll need to investigate further. |
I couldn't find a way to configure the
javadoc_location
of jdt.coreThe text was updated successfully, but these errors were encountered: