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

JsonSyntaxException on startup #546

Open
SrDum opened this issue Jan 15, 2024 · 9 comments
Open

JsonSyntaxException on startup #546

SrDum opened this issue Jan 15, 2024 · 9 comments
Labels
bug Something isn't working editor support Support for any non-VSCode editors/language clients

Comments

@SrDum
Copy link

SrDum commented Jan 15, 2024

Full log follows: lsp.log

This is happening after a clean build (and trying to use it with nvim, using lspconfig). Worth noting that just running the server outside of nvim (while not spamming me with erros like nvim did), still gives teh first warning that seems to be the root cause, that being the line
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"
Now, full disclosure, It's completely possible this is somehow an error on my part while building, but I have already retried multiple times following the readme.md to the letter.

Thanks in advance for any assistence.

@fwcd fwcd added bug Something isn't working editor support Support for any non-VSCode editors/language clients labels Jan 15, 2024
@fwcd
Copy link
Owner

fwcd commented Jan 15, 2024

The SLF4J warning is fine (maybe not fine, but expected 😄).

A delegate object is null, jsonrpc methods of 'public default org.eclipse.lsp4j.services.NotebookDocumentService org.eclipse.lsp4j.services.LanguageServer.getNotebookDocumentService()' are ignored

This is interesting. We don't provide this method, but the client shouldn't call it either since we don't advertise it in the server capabilities.

Internal error: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $

The JSON error confuses me. I'd wager a guess and say that it's generally some misconfiguration on the client-side.

@SrDum
Copy link
Author

SrDum commented Jan 15, 2024

The SLF4J warning is fine (maybe not fine, but expected 😄).

A delegate object is null, jsonrpc methods of 'public default org.eclipse.lsp4j.services.NotebookDocumentService org.eclipse.lsp4j.services.LanguageServer.getNotebookDocumentService()' are ignored

This is interesting. We don't provide this method, but the client shouldn't call it either since we don't advertise it in the server capabilities.

Internal error: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $

The JSON error confuses me. I'd wager a guess and say that it's generally some misconfiguration on the client-side.

I don't doubt it. How would I go about troubleshooting this?

@fwcd
Copy link
Owner

fwcd commented Jan 15, 2024

Consult with the docs/maintainers of the language client you're using or try another client and see if the issues persist.

@SrDum
Copy link
Author

SrDum commented Jan 15, 2024

Consult with the docs/maintainers of the language client you're using or try another client and see if the issues persist.

Alright, thank you.

@xsh005
Copy link

xsh005 commented Jan 25, 2024

@SrDum using the default config for init_options solves this for me, previously I was using init_options = {}

edit: linux machine + neovim 10 nightly

@fwy
Copy link

fwy commented Jan 31, 2024

I had the same JSON-related error when first trying this language server with neovim on Windows, and after a little debugging found that setting the init_options.storagePath property to a valid directory fixed it.

init_options = {
    storagePath = util.path.join(vim.env.XDG_DATA_HOME, "nvim-data"),
},

'util' is require('lspconfig/util'), and the environment variable plus the 'nvim-data' segment references a location on my machine. After starting the language server in neovim, I can see that the file kls_database.db is created there and the fatal error is gone.

Using the default init_options by omitting this property from my lua configuration did not help.

@RimuhRimu
Copy link

I'm getting some sort of JSON error too on a fresh install, I haven't been able to find out what's going on:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp.lua:1308: RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: java.lang.ExceptionInInitializerError\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)\n\tat java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\n\tat java.base/java.lang.Thread.run(Unknown Source)\nCaused by: java.lang.ExceptionInInitializerError\n\tat org.javacs.kt.classpath.BackupClassPathResolverKt.findLocalArtifactDirUsingMaven(BackupClassPathResolver.kt:88)\n\tat org.javacs.kt.classpath.BackupClassPathResolverKt.findLocalArtifact(BackupClassPathResolver.kt:25)\n\tat org.javacs.kt.classpath.BackupClassPathResolverKt.findKotlinStdlib(BackupClassPathResolver.kt:21)\n\tat org.javacs.kt.classpath.WithStdlibResolverKt.wrapWithStdlib(WithStdlibResolver.kt:42)\n\tat org.javacs.kt.classpath.WithStdlibResolverKt.wrapWithStdlibEntries(WithStdlibResolver.kt:17)\n\tat org.javacs.kt.classpath.WithStdlibResolverKt.access$wrapWithStdlibEntries(WithStdlibResolver.kt:1)\n\tat org.javacs.kt.classpath.WithStdlibResolver.getClasspathOrEmpty(WithStdlibResolver.kt:9)\n\tat org.javacs.kt.classpath.FirstNonEmptyClassPathResolver.getClasspathOrEmpty(ClassPathResolver.kt:75)\n\tat org.javacs.kt.CompilerClassPath.refresh(CompilerClassPath.kt:57)\n\tat org.javacs.kt.CompilerClassPath.refresh$default(CompilerClassPath.kt:47)\n\tat org.javacs.kt.CompilerClassPath.addWorkspaceRoot(CompilerClassPath.kt:120)\n\tat org.javacs.kt.KotlinLanguageServer$initialize$1.invoke(KotlinLanguageServer.kt:129)\n\tat org.javacs.kt.KotlinLanguageServer$initialize$1.invoke(KotlinLanguageServer.kt:74)\n\tat org.javacs.kt.util.AsyncExecutor.compute$lambda$2(AsyncExecutor.kt:19)\n\t... 4 more\nCaused by: org.javacs.kt.util.KotlinLSException: No repositories found at $MAVEN_REPOSITORY, $MAVEN_HOME, $M2_HOME or $HOME/.m2\n\tat org.javacs.kt.classpath.HomeKt.<clinit>(Home.kt:22)\n\t... 18 more\n"
stack traceback:
	[C]: in function 'assert'
	/usr/share/nvim/runtime/lua/vim/lsp.lua:1308: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

@kroikie
Copy link

kroikie commented Jun 16, 2024

I'm seeing something similar on kotlin 2.x.x with neovim.

Error executing vim.schedule lua callback: ...pson/opt/nvim-linux64/share/nvim/runtime/lua/vim/lsp.lua:1308: RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: com.google.gson.JsonSyntaxException: java.lang.
IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:31
9)\n\tat java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1702)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Thread
PoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:829)\nCaused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $\n\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFact
ory$Adapter.read(ReflectiveTypeAdapterFactory.java:270)\n\tat com.google.gson.Gson.fromJson(Gson.java:1058)\n\tat com.google.gson.Gson.fromJson(Gson.java:1129)\n\tat com.google.gson.Gson.fromJson(Gson.java:1101)\n\tat org.javacs.kt.ConfigurationKt.getStoragePath(Configura
tion.kt:64)\n\tat org.javacs.kt.KotlinLanguageServer$initialize$1.invoke(KotlinLanguageServer.kt:97)\n\tat org.javacs.kt.KotlinLanguageServer$initialize$1.invoke(KotlinLanguageServer.kt:74)\n\tat org.javacs.kt.util.AsyncExecutor.compute$lambda$2(AsyncExecutor.kt:19)\n\tat
 java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)\n\t... 3 more\nCaused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $\n\tat com.google.gson.internal.bind.JsonTreeReader.expect(JsonTree
Reader.java:163)\n\tat com.google.gson.internal.bind.JsonTreeReader.beginObject(JsonTreeReader.java:88)\n\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:259)\n\t... 11 more\n"
stack traceback:
        [C]: in function 'assert'
        ...pson/opt/nvim-linux64/share/nvim/runtime/lua/vim/lsp.lua:1308: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

This happens on opening a Kotlin file so I'm not able to use the language server yet :)

@fwcd
Copy link
Owner

fwcd commented Jul 28, 2024

@RimuhRimu #546 (comment) looks like a duplicate of #564

By the way, it would be great if you (all) could pretty-print the stack traces (i.e. replace \ns with newlines) and ideally file separate issues for different exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working editor support Support for any non-VSCode editors/language clients
Projects
None yet
Development

No branches or pull requests

6 participants