You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[vscode] Extension never activates, throwing error "Header must provide a Content-Length property" #811
Describe the bug
As per the title, the extension never activates. The developer tools shows uncaught error: Header must provide a Content-Length property.
To Reproduce
The bug just happened. Tried to downgrade the extension version but doesn't works. Also tried to reinstall VSC but doesn't works.
@MarcSerret51 which version of vscode? What is the OS (Win? OSX?) What is the path of the project you're opening in VSCode?
The error is JSON RPC issue... content length is different from the actual content length is worrisome :-\ I suspect that one of the JSON messages coming from Boot languafe server to VSCode has a URI with some escaped chars probably or non-printable chars or something like it and hence the length that lsp4j lib computes is different from the actual size of the message... hence the questions above... Would be great to get to the bottom of this
I'm using VSC 1.7.0 on a Windows 10 NT 64 bits 10.0.19044.
The project path is C:\projects\sources\workspace\EPVT but it also happens with a mini project that I have on the desktop.
It is good to note that I got this bug redhat-developer/vscode-java#2577 on the vscode-java extension that this comment redhat-developer/vscode-java#2577 (comment) solved.
I've been usign both extensions for 3 years without any problem and suddenly both broke.
@MarcSerret51 So does adding the workaround, as described here (redhat-developer/vscode-java#2577 (comment)) solves the issue for you for the Spring Tools extension as well? It seems to me like the magic VM argument needs to be added to both extensions (the Java one AND the Spring Tools).
If so, we could think about adding this to the default VM args for launching the language server as well, as done here: redhat-developer/vscode-java#2646
I too have been having problems since around 8/9
SO,I adding -Xlog:disable to java.jdt.ls.vmargs.
In my case -Xlog:jni+resolve=off did not fix it.
Today, Spring Boot Tools was updated to v1.39.0, it stopped working again...
I tried change settings to -Xlog:jni+resolve=off, -Xlog:disable and not set -Xlog properties.
However, the message Header must provide a Content-Length property is still displayed and it does not work.
It works after installing Spring Boot Tools V1.38.0 and setting -Xlog:disable.
Maybe in v1.39.0 vmargs is set at -Xlog:disable -Xlog:jni+resolve=off ?
@MunekazuF it is just -Xlog:jni+resolve=off in 1.39. I'll have a look but if you provide your own -Xlog:jni+resolve and -Xlog they should be respected. Do you mind starting jconsole and connecting BootLanguageServer java process and seeing the VM args the process was started with? This would clarify the issue...
I had the same error saying "Header must provide a Content-Length property". I was not able to run any Spring Boot application nor any unit tests etc.
VSCode v1.71.2
pivotal.vscode-spring-boot v1.39.0
Setting spring-boot.ls.java.vmargs=-Xlog:jni+resolve=off didn't fix the problem. The same error occurred in developer tools. However, setting spring-boot.ls.java.vmargs=-Xlog:disable fixed it and now I can run my Spring Boot project again (including unit tests).
@BoykoAlex I would say, this issue should be re-opened as it is not fixed with -Xlog:jni+resolve=off.
@depressiveRobot do you need to add the same VM arg to the JDT LS launch? I don't think that JDT LS has -Xlog:disable by default which makes this somewhat questionable for the Boot LS. What are the JVM args of the running Boot App? What does JConsole show you?
(I suspect that you may have a special VM agent on your system as noted a few comments above which might be writing in the output stream interfering with LS <-> IDE comm)
@BoykoAlex No, I don't need to set the same arg for java.jdt.ls.vmargs.
What are the JVM args of the running Boot App? What does JConsole show you?
Without setting spring-boot.ls.java.vmargs=-Xlog:disable the Boot app doesn't start at all. VSCode hangs forever without any output in the lower panel (neither terminal, debug console or output tab).
Here is the launch command after changing the setting to -Xlog:disable:
@depressiveRobot can you please try turning off (uncheck) Auto-Connect to live app? It is under Spring Boot Tools settings, key is boot-java.live-information.automatic-connection.on. Try starting the app without auto-connect. This is the only feature that messes with the java launch in vscode. If it is off the launch should be identical to the java extension.
I suppose disabling Spring Boot Tools extension fixes the issue for you at the moment as well, correct?
What is the @/var/folders/kl/vr0sf8_s78g4d77lq0xlvdz80000gn/T/cp_2ipjusatg6zzkp5pl66ldquv1.argfile? A file with more VM args?
@depressiveRobot What about the VM args of the Spring Boot LS java process? What are the VM arguments for BootLanguageServerBootApp process in JConsole?
@depressiveRobot What about the VM args of the Spring Boot LS java process? What are the VM arguments for BootLanguageServerBootApp process in JConsole?
@BoykoAlex can you please describe how to get this information for you?
Ensure that VSCode (with Java and Spring Boot Tools extensions installed) is opened with a java file from Spring Boot project opened in the editor. Essentially this step ensures that Boot LS process is started.
Start jconsole from <JAVA_HOME>/bin/jconsole
JConsole UI should show you a list of running java processes. Find org.springframework.ide.vscode.boot.app.BootLanguageServerBootApp in the list and connect to it using the Connect button in the UI
Click on the VM Summary tab and then find VM Arguments in the table.
I have there something like:
After reading through this again, I have a few questions/suggestions here:
as mentioned as few times here, the -Xlog:disable setting seems to solve the issue with the Spring Boot LS not starting or running correctly - even though we don't know exactly what is causing the Spring Boot LS to stop working without that setting. Can we find out what exactly is causing the Spring Boot LS to stop working without that setting? The assumption is that something is dumping log output to the stdout and causing the communication between VSCode and the Spring Boot LS to break (seems very likely), but can we somehow see the log output that is causing the breakage? That is written to that stream that causes this?
once we know what exactly is causing the wrong log output, we might get an idea about why this setting is not needed for the Java LS, but it is needed for the Spring Boot LS - e.g. if the code that dumps the wrong output to the stdout stream doesn't exist or isn't executed in the Java LS.
we could and probably should discuss with the Java LS team whether we should align and have -Xlog:disable instead of -Xlog:jni+resolve=off across the place and what they think about it.
Beyond that, it is still unclear to me why launching a Spring Boot app or a test is broken when the Spring Boot LS has a problem to start or to run. Can we make this more resilient, so that starting/testing apps doesn't break when the Spring Boot LS has such an issue? I remember issues being raised about running tests doesn't work anymore when the Sprint Boot extension is around and it sounds to me related to this one here.
@depressiveRobot Lets continue trying to figure out why -Xlog:disable is necessary in your case as @martinlippert suggested.
Close all editors in your vscode.
Open settings.json (Crtl-Shift-P to open command palette, find the command Preferences: Open User Settings (JSON)
Add the following "vscode-spring-boot.trace.server": "verbose" in the settings.json to trace all messages between Boot LS process and VSCode client
Activate Output tab in the view on the bottom. Select vscode-spring-boot-debug-log in the drop-down located in the top-right corner of the view on the bottom.
Open application.properties file from the Spring Boot project and now try to find which of the messages has some extra content and what that content is. Likely you're going to find some log messages in the middle of regular JSON objects which pollute JSON... I suspect it'd be something rather obvious.
I commented/removed "spring-boot.ls.java.vmargs": ["-Xlog:disable"] (to have a non-working Spring Boot extension) and added the "vscode-spring-boot.trace.server": "verbose" tosettings.json (there are no other settings with key containing *spring-boot*)
Here is the output of the vscode-spring-boot-debug-log output tab:
That's it. Nothing happens when opening application.yml of my Spring Boot project.
When I uncomment/add "spring-boot.ls.java.vmargs": ["-Xlog:disable"] again, I see a lot of messages in the vscode-spring-boot-debug-log output tab (despite the message Disabling server log output. No more output will be sent after this.). For example, when hovering over a property in application.yml:
...
[Trace - 3:06:19 PM] Received response 'textDocument/hover - (44)' in 13ms.
Result: {
"contents": "**management.endpoints.web.base-path** \n[java.lang.String](null) \n\nDefault: */actuator* \n\nBase path for Web endpoints. Relative to the servlet context path (server.servlet.context-path) or WebFlux base path (spring.webflux.base-path) when the management server is sharing the main server port. Relative to the management server base path (management.server.base-path) when a separate management server port (management.server.port) is configured.\n",
"range": {
"start": {
"line": 29,
"character": 6
},
"end": {
"line": 29,
"character": 15
}
}
}
...
@depressiveRobot looked through the JSON - this is the 1st request sent from the client to the server. Looks like the first response from the server either not sent or sent but not handled by the client... Do you get the error about the Content-Length property not set or actual content-length not equal to the one declared in the header? I mean the error at the top of the issue... Looked through the comments again and it looks to me like there is no error, complete silence from the Boot LS <-> VScode comm. Is this correct?
There is something i didn't like in the spring boot log:
"spring-boot.ls.java.home" setting not specified or empty value
"java.home" setting not specified or empty value
No user specified java-home setting. Looking for JAVA_HOME env variable...
Found java executable: /opt/homebrew/Cellar/openjdk@11/11.0.16.1_1/libexec/openjdk.jdk/Contents/Home/bin/java
The vscode java extension comes with embedded jre already. Spring Boot LS should have used it by default. However, I see that for some reason boot tools extension fell back to using your system JAVA_HOME setting instead.
The JVM used to start boot ls for me is:
Do you get the error about the Content-Length property not set or actual content-length not equal to the one declared in the header? I mean the error at the top of the issue... Looked through the comments again and it looks to me like there is no error, complete silence from the Boot LS <-> VScode comm. Is this correct?
Yes, without the setting spring-boot.ls.java.vmargs=-Xlog:disable I get the error "Header must provide a Content-Length property" and no messages between Boot LS and VSCode.
For me the JVM used to start org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar is:
I could change the LS Java home setting. However, I assume that the extension is using the "right" JVM by default (without the need to change any setting like spring-boot.ls.java.home).
These are all my configured Java settings in VSCode:
I'm curious if it has anything to do with the content-length error... Looks like java LS uses JVM 17...
There is also a way to debug the place that throws the error...
Clone sts4 git repo.
Open `vscode-extensions/vscode-spring-boot folder in VSCode
Ensure that terminal in vscode has java home set to java 11 to run the build.
Run npm install then run ./build.sh
Press F5 to launch runtime VSCode
Open your spring boot project in the runtime VSCode then open a java file from the project.
Observe the error. It should point at vscode-spring-boot/node_modules/vscode-jsonrpc/lin/common/... somewhere.
Put a breakpoint in VSCode in the file at the line that throws the error and try making sense of the json rpc message... convert it to string from bytes using debugger somehow (I may advise something for this tomorrow)
Activity
BoykoAlex commentedon Aug 9, 2022
@MarcSerret51 which version of vscode? What is the OS (Win? OSX?) What is the path of the project you're opening in VSCode?
The error is JSON RPC issue... content length is different from the actual content length is worrisome :-\ I suspect that one of the JSON messages coming from Boot languafe server to VSCode has a URI with some escaped chars probably or non-printable chars or something like it and hence the length that lsp4j lib computes is different from the actual size of the message... hence the questions above... Would be great to get to the bottom of this
MarcSerret51 commentedon Aug 10, 2022
I'm using VSC 1.7.0 on a Windows 10 NT 64 bits 10.0.19044.
The project path is
C:\projects\sources\workspace\EPVTbut it also happens with a mini project that I have on the desktop.It is good to note that I got this bug redhat-developer/vscode-java#2577 on the
vscode-javaextension that this comment redhat-developer/vscode-java#2577 (comment) solved.I've been usign both extensions for 3 years without any problem and suddenly both broke.
martinlippert commentedon Aug 29, 2022
@MarcSerret51 So does adding the workaround, as described here (redhat-developer/vscode-java#2577 (comment)) solves the issue for you for the Spring Tools extension as well? It seems to me like the magic VM argument needs to be added to both extensions (the Java one AND the Spring Tools).
martinlippert commentedon Aug 29, 2022
If so, we could think about adding this to the default VM args for launching the language server as well, as done here: redhat-developer/vscode-java#2646
BoykoAlex commentedon Sep 6, 2022
Fixed with aadf4a0
MunekazuF commentedon Sep 16, 2022
I too have been having problems since around 8/9
SO,I adding
-Xlog:disableto java.jdt.ls.vmargs.In my case
-Xlog:jni+resolve=offdid not fix it.Today, Spring Boot Tools was updated to v1.39.0, it stopped working again...
I tried change settings to
-Xlog:jni+resolve=off,-Xlog:disableand not set -Xlog properties.However, the message
Header must provide a Content-Length propertyis still displayed and it does not work.It works after installing Spring Boot Tools V1.38.0 and setting
-Xlog:disable.Maybe in v1.39.0 vmargs is set at
-Xlog:disable -Xlog:jni+resolve=off?I'm using VSC 1.71.2 on Windows 10.
BoykoAlex commentedon Sep 16, 2022
@MunekazuF it is just
-Xlog:jni+resolve=offin 1.39. I'll have a look but if you provide your own-Xlog:jni+resolveand -Xlogthey should be respected. Do you mind startingjconsoleand connecting BootLanguageServer java process and seeing the VM args the process was started with? This would clarify the issue...8 remaining items
depressiveRobot commentedon Sep 28, 2022
Here is my experience with the problem:
I had the same error saying "Header must provide a Content-Length property". I was not able to run any Spring Boot application nor any unit tests etc.
VSCode v1.71.2
pivotal.vscode-spring-boot v1.39.0
Setting
spring-boot.ls.java.vmargs=-Xlog:jni+resolve=offdidn't fix the problem. The same error occurred in developer tools. However, settingspring-boot.ls.java.vmargs=-Xlog:disablefixed it and now I can run my Spring Boot project again (including unit tests).@BoykoAlex I would say, this issue should be re-opened as it is not fixed with
-Xlog:jni+resolve=off.BoykoAlex commentedon Sep 28, 2022
@depressiveRobot do you need to add the same VM arg to the JDT LS launch? I don't think that JDT LS has
-Xlog:disableby default which makes this somewhat questionable for the Boot LS. What are the JVM args of the running Boot App? What does JConsole show you?(I suspect that you may have a special VM agent on your system as noted a few comments above which might be writing in the output stream interfering with LS <-> IDE comm)
depressiveRobot commentedon Sep 28, 2022
@BoykoAlex No, I don't need to set the same arg for
java.jdt.ls.vmargs.Without setting
spring-boot.ls.java.vmargs=-Xlog:disablethe Boot app doesn't start at all. VSCode hangs forever without any output in the lower panel (neither terminal, debug console or output tab).Here is the launch command after changing the setting to
-Xlog:disable:BoykoAlex commentedon Sep 28, 2022
@depressiveRobot can you please try turning off (uncheck) Auto-Connect to live app? It is under
Spring Boot Toolssettings, key isboot-java.live-information.automatic-connection.on. Try starting the app without auto-connect. This is the only feature that messes with the java launch in vscode. If it is off the launch should be identical to the java extension.I suppose disabling Spring Boot Tools extension fixes the issue for you at the moment as well, correct?
What is the
@/var/folders/kl/vr0sf8_s78g4d77lq0xlvdz80000gn/T/cp_2ipjusatg6zzkp5pl66ldquv1.argfile? A file with more VM args?depressiveRobot commentedon Sep 28, 2022
The option is already unchecked.
Right, without the extension I can run my app, too.
It contains the
-cpargument with all dependencies (*.jarfiles).BoykoAlex commentedon Sep 28, 2022
@depressiveRobot What about the VM args of the Spring Boot LS java process? What are the VM arguments for
BootLanguageServerBootAppprocess in JConsole?depressiveRobot commentedon Sep 28, 2022
@BoykoAlex can you please describe how to get this information for you?
BoykoAlex commentedon Sep 28, 2022
@depressiveRobot
jconsolefrom<JAVA_HOME>/bin/jconsoleorg.springframework.ide.vscode.boot.app.BootLanguageServerBootAppin the list and connect to it using the Connect button in the UII have there something like:
martinlippert commentedon Sep 29, 2022
After reading through this again, I have a few questions/suggestions here:
-Xlog:disablesetting seems to solve the issue with the Spring Boot LS not starting or running correctly - even though we don't know exactly what is causing the Spring Boot LS to stop working without that setting. Can we find out what exactly is causing the Spring Boot LS to stop working without that setting? The assumption is that something is dumping log output to the stdout and causing the communication between VSCode and the Spring Boot LS to break (seems very likely), but can we somehow see the log output that is causing the breakage? That is written to that stream that causes this?-Xlog:disableinstead of-Xlog:jni+resolve=offacross the place and what they think about it.Beyond that, it is still unclear to me why launching a Spring Boot app or a test is broken when the Spring Boot LS has a problem to start or to run. Can we make this more resilient, so that starting/testing apps doesn't break when the Spring Boot LS has such an issue? I remember issues being raised about running tests doesn't work anymore when the Sprint Boot extension is around and it sounds to me related to this one here.
depressiveRobot commentedon Sep 29, 2022
@BoykoAlex Thank you for the detailed description. Here are the VM arguments:
As I said, without
spring-boot.ls.java.vmargs=-Xlog:disablethe Spring Boot LS doesn't start at all.BoykoAlex commentedon Sep 29, 2022
@depressiveRobot Lets continue trying to figure out why
-Xlog:disableis necessary in your case as @martinlippert suggested.settings.json(Crtl-Shift-P to open command palette, find the command Preferences: Open User Settings (JSON)"vscode-spring-boot.trace.server": "verbose"in thesettings.jsonto trace all messages between Boot LS process and VSCode clientvscode-spring-boot-debug-login the drop-down located in the top-right corner of the view on the bottom.application.propertiesfile from the Spring Boot project and now try to find which of the messages has some extra content and what that content is. Likely you're going to find some log messages in the middle of regular JSON objects which pollute JSON... I suspect it'd be something rather obvious.depressiveRobot commentedon Sep 30, 2022
@BoykoAlex
I commented/removed
"spring-boot.ls.java.vmargs": ["-Xlog:disable"](to have a non-working Spring Boot extension) and added the"vscode-spring-boot.trace.server": "verbose"tosettings.json(there are no other settings with key containing*spring-boot*)Here is the output of the
vscode-spring-boot-debug-logoutput tab:That's it. Nothing happens when opening
application.ymlof my Spring Boot project.When I uncomment/add
"spring-boot.ls.java.vmargs": ["-Xlog:disable"]again, I see a lot of messages in thevscode-spring-boot-debug-logoutput tab (despite the messageDisabling server log output. No more output will be sent after this.). For example, when hovering over a property inapplication.yml:BoykoAlex commentedon Sep 30, 2022
@depressiveRobot looked through the JSON - this is the 1st request sent from the client to the server. Looks like the first response from the server either not sent or sent but not handled by the client... Do you get the error about the Content-Length property not set or actual content-length not equal to the one declared in the header? I mean the error at the top of the issue... Looked through the comments again and it looks to me like there is no error, complete silence from the Boot LS <-> VScode comm. Is this correct?
There is something i didn't like in the spring boot log:
The vscode java extension comes with embedded jre already. Spring Boot LS should have used it by default. However, I see that for some reason boot tools extension fell back to using your system
JAVA_HOMEsetting instead.The JVM used to start boot ls for me is:
Once you open java file in VSCode, open JConsole and check the JVM used to run
org.eclipse.equinox.launcher_1.6.400.... Hope it is the embedded JRE.I'd set the spring boot LS java home setting to that embedded JVM value:
depressiveRobot commentedon Oct 1, 2022
@BoykoAlex
Yes, without the setting
spring-boot.ls.java.vmargs=-Xlog:disableI get the error "Header must provide a Content-Length property" and no messages between Boot LS and VSCode.For me the JVM used to start
org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jaris:I could change the LS Java home setting. However, I assume that the extension is using the "right" JVM by default (without the need to change any setting like
spring-boot.ls.java.home).These are all my configured Java settings in VSCode:
Update
I have installed another version of the extension that doesn't ship a JRE:
By the way, I'm using a MacBook Air M1. Maybe that could play a role.
BoykoAlex commentedon Oct 3, 2022
Something must be polluting sys out... I also have a mac m1 (great machine by the way) and seems to work fine so far for me.
Can you please try the same JVM that runs Java LS with the Boot LS? I recall that JVM for running Boot LS was:
I'm curious if it has anything to do with the content-length error... Looks like java LS uses JVM 17...
There is also a way to debug the place that throws the error...
npm installthen run./build.shvscode-spring-boot/node_modules/vscode-jsonrpc/lin/common/...somewhere.