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

JDTLanguageServer cannot run well without IApplication #2311

Closed
Tracked by #2354
mickaelistria opened this issue Nov 7, 2022 · 2 comments
Closed
Tracked by #2354

JDTLanguageServer cannot run well without IApplication #2311

mickaelistria opened this issue Nov 7, 2022 · 2 comments

Comments

@mickaelistria
Copy link
Contributor

While trying to run the language server via code (in a Java process, as part of an Eclipse IDE plugin), it looks like the only vaid entry-point is the LanguageServer implements IApplication. However, this one does force to use some streams accoridng to application execution context.
If one tries to bypass it, directly calling the JDTLanguageServer, there are some issues later on as the execution flow of the language server goes through the JavaLanguageServerPlugin to access some fields, which are only set (and settable) from the LanguageServer/IApplication; so another client cannot set those fields.
The JavaLanguageServerPlugin should allow to have those fields set, or JDT-LS should provide a dedicated launcher that would allow to use any stream (typically some java.nio.channels.Pipe ) and that would set up all the necessary state.

Here is the error I get

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	... 11 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.ls.core.internal.LanguageServer.setParentProcessId(long)" because the return value of "org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.getLanguageServer()" is null
	at org.eclipse.jdt.ls.core.internal.handlers.BaseInitHandler.handleInitializationOptions(BaseInitHandler.java:155)
	at org.eclipse.jdt.ls.core.internal.handlers.InitHandler.handleInitializationOptions(InitHandler.java:88)
	at org.eclipse.jdt.ls.core.internal.handlers.BaseInitHandler.initialize(BaseInitHandler.java:63)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.initialize(JDTLanguageServer.java:256)
	... 16 more

Nov 07, 2022 11:02:45 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleNotification
WARNING: Notification threw an exception: {
  "jsonrpc": "2.0",
  "method": "exit",
  "params": null
}
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	... 11 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.ls.core.internal.LanguageServer.exit()" because the return value of "org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.getLanguageServer()" is null
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.exit(JDTLanguageServer.java:453)
	... 16 more
@mickaelistria
Copy link
Contributor Author

This tweak has unblocked me: mickaelistria@0f7b0aa ; but I think a better place where to store such processId would actually be the JDTLanguageServer instance (as we can now see other startup are possible, and maybe even imagine the plugin serving multiplt JDTLanguageServer at the same time)..

@mickaelistria mickaelistria changed the title JDTLanguageServer cannot run well without IApplicatio JDTLanguageServer cannot run well without IApplication Nov 8, 2022
mickaelistria added a commit to mickaelistria/eclipse.jdt.ls that referenced this issue Nov 9, 2022
Remove an execution path that only works if IApplication is running; so
JDT-LS can be used in different deployments.

Part of eclipse-jdtls#2311
@rgrunber rgrunber added this to the End November milestone Nov 14, 2022
@rgrunber
Copy link
Contributor

I think this makes sense. If a client wants to have their own "Application" to handle the JDT-LS startup, then that's valid, and we should support them.

mickaelistria added a commit to mickaelistria/eclipse.jdt.ls that referenced this issue Nov 14, 2022
Remove an execution path that only works if IApplication is running; so
JDT-LS can be used in different deployments.

Part of eclipse-jdtls#2311
rgrunber pushed a commit to mickaelistria/eclipse.jdt.ls that referenced this issue Nov 15, 2022
Remove an execution path that only works if IApplication is running; so
JDT-LS can be used in different deployments.

Part of eclipse-jdtls#2311
rgrunber pushed a commit that referenced this issue Nov 15, 2022
Remove an execution path that only works if IApplication is running; so
JDT-LS can be used in different deployments.

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

No branches or pull requests

2 participants