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

[vscode] Extension never activates, throwing error "Header must provide a Content-Length property" #811

Closed
MarcSerret51 opened this issue Aug 9, 2022 · 30 comments
Assignees
Labels
for: vscode something that is specific for VSCode status: needs-investigation type: bug

Comments

@MarcSerret51
Copy link

Describe the bug
As per the title, the extension never activates. The developer tools shows uncaught error: Header must provide a Content-Length property.
image

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.

@BoykoAlex
Copy link
Contributor

@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
Copy link
Author

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.

@martinlippert
Copy link
Member

@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
Copy link
Member

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

@martinlippert martinlippert added this to the 4.16.0.RELEASE milestone Aug 29, 2022
@BoykoAlex
Copy link
Contributor

Fixed with aadf4a0

@MunekazuF
Copy link

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 ?

I'm using VSC 1.71.2 on Windows 10.

@BoykoAlex
Copy link
Contributor

BoykoAlex commented Sep 16, 2022

@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...

@MunekazuF
Copy link

@BoykoAlex I checked with jconsole and this is what I found.

-Xss2048k -Xmx1024m -Dsts.lsp.client=vscode -Dsts.log.file=/dev/null -XX:TieredStopAtLevel=1 -Xlog:jni+resolve=off -Dspring.config.location=file:c:\Users\xxxxx\.vscode\extensions\pivotal.vscode-spring-boot-1.39.0\language-server\BOOT-INF\classes\application.properties -agentpath:C:\Program Files\Palo Alto Networks\Traps\cyjagent.dll

it's Just -Xlog:jni+resolve=off
However, this does not work in my case.

Language Support for Java was not working with the same problem, but now it works with this setting.
"java.jdt.ls.vmargs": "-Xlog:jni+resolve=off",

This is how it is set up in spring boot.
"spring-boot.ls.java.vmargs": [ "-Xlog:disable" ], //"-Xlog:jni+resolve=off" //not work

thanks.

@BoykoAlex
Copy link
Contributor

My understanding is that you'd like -Xlog:disable to be one of the VM args for the boot ls process, correct?
You've tried adding -Xlog:disable via "spring-boot.ls.java.vmargs": [ "-Xlog:disable" ] in the settings.json and it didn't work?

The VM args above are missing -Xlog:disable for some reason... I've tried adding the same VM argument in my VSCode with 1.39 installed:

    "spring-boot.ls.java.vmargs": [
        "-Xlog:disable"
    ],

(via the VSCode preferences UI but editing settings.json directly should work the same)

It worked fine. I see -Xlog:disable in the vm args for the Bot LS java app in the jconsole. Thus I'm very confused :-\

@MunekazuF
Copy link

@BoykoAlex I am really sorry,I made a rudimentary mistake.
I have overwritten User settings with Workspace settings...
I added -Xlog:disable and it works.

In other words, it was working without the -Xlog:disable setting in 1.38.0, but -Xlog:jni+resolve=off setting was added in 1.39.0 and stopped working.

My issue has been resolved.
However, it is strange that it does not work with the settings as everyone else.

@BoykoAlex
Copy link
Contributor

Perhaps we could add -Xlog:disable by default as well... It'd be obvious to add it if Java extension would be adding this VM argument by default as well.

@martinlippert
Copy link
Member

What is the -agentpath:C:\Program Files\Palo Alto Networks\Traps\cyjagent.dll part all about? I don't think this is something that comes as a default here from the tooling. Might this dump information on stdio/stdout that prevents the communication between the language server and VSCode from working?

@MunekazuF
Copy link

@martinlippert You may be right.
My PC has Cortex XDR installed by my company. Cortex XDR is endpoint protection system, and This DLL seems to be from that software.

@martinlippert
Copy link
Member

It sounds to me like the -Xlog:disable switches off all logging, so it should include the more special variant -Xlog:jni+resolve=off, which only switches off logging for jni things.

@martinlippert
Copy link
Member

@depressiveRobot
Copy link

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=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.

@BoykoAlex
Copy link
Contributor

@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)

@depressiveRobot
Copy link

@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:

/usr/bin/env /opt/homebrew/Cellar/openjdk@11/11.0.16.1_1/libexec/openjdk.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:51644 @/v
ar/folders/kl/vr0sf8_s78g4d77lq0xlvdz80000gn/T/cp_2ipjusatg6zzkp5pl66ldquv1.argfile de.gruenefraktionsachsen.saxdhh.SaxdhhApp

@BoykoAlex
Copy link
Contributor

BoykoAlex commented Sep 28, 2022

@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
Copy link

can you please try turning off (uncheck) Auto-Connect to live app?

The option is already unchecked.

I suppose disabling Spring Boot Tools extension fixes the issue for you at the moment as well, correct?

Right, without the extension I can run my app, too.

What is the @/var/folders/kl/vr0sf8_s78g4d77lq0xlvdz80000gn/T/cp_2ipjusatg6zzkp5pl66ldquv1.argfile? A file with more VM args?

It contains the -cp argument with all dependencies (*.jar files).

@BoykoAlex
Copy link
Contributor

@depressiveRobot What about the VM args of the Spring Boot LS java process? What are the VM arguments for BootLanguageServerBootApp process in JConsole?

@depressiveRobot
Copy link

@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?

@BoykoAlex
Copy link
Contributor

BoykoAlex commented Sep 28, 2022

@depressiveRobot

  1. 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.
  2. Start jconsole from <JAVA_HOME>/bin/jconsole
  3. 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
  4. Click on the VM Summary tab and then find VM Arguments in the table.
    I have there something like:
-Dsts.lsp.client=eclipse                  -Dlsp.completions.indentation.enable=true -Xmx1024m -XX:TieredStopAtLevel=1                  -Xlog:jni+resolve=off -Dspring.config.location=file:/Applications/STS-4.16.0-e4.25.app/Contents/Eclipse/plugins/org.springframework.tooling.boot.ls_1.39.0.202209151102/servers/spring-boot-language-server/BOOT-INF/classes/application.properties

@martinlippert
Copy link
Member

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
Copy link

@BoykoAlex Thank you for the detailed description. Here are the VM arguments:

-Xlog:disable -Dsts.lsp.client=vscode -Dsts.log.file=/dev/null -XX:TieredStopAtLevel=1 -Xlog:jni+resolve=off -Dspring.config.location=file:/Users/depressiveRobot/.vscode-oss/extensions/pivotal.vscode-spring-boot-1.39.0/language-server/BOOT-INF/classes/application.properties 

As I said, without spring-boot.ls.java.vmargs=-Xlog:disable the Spring Boot LS doesn't start at all.

@BoykoAlex
Copy link
Contributor

@depressiveRobot Lets continue trying to figure out why -Xlog:disable is necessary in your case as @martinlippert suggested.

  1. Close all editors in your vscode.
  2. Open settings.json (Crtl-Shift-P to open command palette, find the command Preferences: Open User Settings (JSON)
  3. Add the following "vscode-spring-boot.trace.server": "verbose" in the settings.json to trace all messages between Boot LS process and VSCode client
  4. 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.
  5. 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.

@depressiveRobot
Copy link

depressiveRobot commented 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-log output tab:

Activating 'vscode-spring-boot' extension
"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
isJavaEightOrHigher => true
Redirecting server logs to /dev/null
[Trace - 2:54:11 PM] Sending request 'initialize - (0)'.
Params: {
    "processId": 72995,
    "clientInfo": {
        "name": "VSCodium",
        "version": "1.71.2"
    },
    "locale": "en-us",
    "rootPath": "/Users/...",
    "rootUri": "file:///Users/...",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "textOnlyTransactional",
                "normalizesLineEndings": true,
                "changeAnnotationSupport": {
                    "groupsOnLabel": true
                }
            },
            "configuration": true,
            "didChangeWatchedFiles": {
                "dynamicRegistration": true,
                "relativePatternSupport": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                },
                "resolveSupport": {
                    "properties": [
                        "location.range"
                    ]
                }
            },
            "codeLens": {
                "refreshSupport": true
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "workspaceFolders": true,
            "semanticTokens": {
                "refreshSupport": true
            },
            "fileOperations": {
                "dynamicRegistration": true,
                "didCreate": true,
                "didRename": true,
                "didDelete": true,
                "willCreate": true,
                "willRename": true,
                "willDelete": true
            },
            "inlineValue": {
                "refreshSupport": true
            },
            "inlayHint": {
                "refreshSupport": true
            },
            "diagnostics": {
                "refreshSupport": true
            }
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true,
                "versionSupport": false,
                "tagSupport": {
                    "valueSet": [
                        1,
                        2
                    ]
                },
                "codeDescriptionSupport": true,
                "dataSupport": true
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true,
                    "tagSupport": {
                        "valueSet": [
                            1
                        ]
                    },
                    "insertReplaceSupport": true,
                    "resolveSupport": {
                        "properties": [
                            "documentation",
                            "detail",
                            "additionalTextEdits"
                        ]
                    },
                    "insertTextModeSupport": {
                        "valueSet": [
                            1,
                            2
                        ]
                    },
                    "labelDetailsSupport": true
                },
                "insertTextMode": 2,
                "completionItemKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25
                    ]
                },
                "completionList": {
                    "itemDefaults": [
                        "commitCharacters",
                        "editRange",
                        "insertTextFormat",
                        "insertTextMode"
                    ]
                }
            },
            "hover": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "parameterInformation": {
                        "labelOffsetSupport": true
                    },
                    "activeParameterSupport": true
                },
                "contextSupport": true
            },
            "definition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "references": {
                "dynamicRegistration": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "hierarchicalDocumentSymbolSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                },
                "labelSupport": true
            },
            "codeAction": {
                "dynamicRegistration": true,
                "isPreferredSupport": true,
                "disabledSupport": true,
                "dataSupport": true,
                "resolveSupport": {
                    "properties": [
                        "edit"
                    ]
                },
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                },
                "honorsChangeAnnotations": false
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true,
                "prepareSupport": true,
                "prepareSupportDefaultBehavior": 1,
                "honorsChangeAnnotations": true
            },
            "documentLink": {
                "dynamicRegistration": true,
                "tooltipSupport": true
            },
            "typeDefinition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "implementation": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true,
                "foldingRangeKind": {
                    "valueSet": [
                        "comment",
                        "imports",
                        "region"
                    ]
                },
                "foldingRange": {
                    "collapsedText": false
                }
            },
            "declaration": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "selectionRange": {
                "dynamicRegistration": true
            },
            "callHierarchy": {
                "dynamicRegistration": true
            },
            "semanticTokens": {
                "dynamicRegistration": true,
                "tokenTypes": [
                    "namespace",
                    "type",
                    "class",
                    "enum",
                    "interface",
                    "struct",
                    "typeParameter",
                    "parameter",
                    "variable",
                    "property",
                    "enumMember",
                    "event",
                    "function",
                    "method",
                    "macro",
                    "keyword",
                    "modifier",
                    "comment",
                    "string",
                    "number",
                    "regexp",
                    "operator",
                    "decorator"
                ],
                "tokenModifiers": [
                    "declaration",
                    "definition",
                    "readonly",
                    "static",
                    "deprecated",
                    "abstract",
                    "async",
                    "modification",
                    "documentation",
                    "defaultLibrary"
                ],
                "formats": [
                    "relative"
                ],
                "requests": {
                    "range": true,
                    "full": {
                        "delta": true
                    }
                },
                "multilineTokenSupport": false,
                "overlappingTokenSupport": false,
                "serverCancelSupport": true,
                "augmentsSyntaxTokens": true
            },
            "linkedEditingRange": {
                "dynamicRegistration": true
            },
            "typeHierarchy": {
                "dynamicRegistration": true
            },
            "inlineValue": {
                "dynamicRegistration": true
            },
            "inlayHint": {
                "dynamicRegistration": true,
                "resolveSupport": {
                    "properties": [
                        "tooltip",
                        "textEdits",
                        "label.tooltip",
                        "label.location",
                        "label.command"
                    ]
                }
            },
            "diagnostic": {
                "dynamicRegistration": true,
                "relatedDocumentSupport": false
            }
        },
        "window": {
            "showMessage": {
                "messageActionItem": {
                    "additionalPropertiesSupport": true
                }
            },
            "showDocument": {
                "support": true
            },
            "workDoneProgress": true
        },
        "general": {
            "staleRequestSupport": {
                "cancel": true,
                "retryOnContentModified": [
                    "textDocument/semanticTokens/full",
                    "textDocument/semanticTokens/range",
                    "textDocument/semanticTokens/full/delta"
                ]
            },
            "regularExpressions": {
                "engine": "ECMAScript",
                "version": "ES2020"
            },
            "markdown": {
                "parser": "marked",
                "version": "1.1.0"
            },
            "positionEncodings": [
                "utf-16"
            ]
        },
        "notebookDocument": {
            "synchronization": {
                "dynamicRegistration": true,
                "executionSummarySupport": true
            }
        }
    },
    "initializationOptions": {
        "workspaceFolders": [
            "file:///Users/..."
        ],
        "enableJdtClasspath": true
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///Users/...",
            "name": "saxdhh"
        }
    ]
}


Disabling server log output. No more output will be sent after this.

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
        }
    }
}
...

@BoykoAlex
Copy link
Contributor

@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:

/Users/aboyko/.vscode/extensions/redhat.java-1.11.0-darwin-x64/jre/17.0.4.1-macosx-x86_64/bin/java

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:

"spring-boot.ls.java.home": "/Users/aboyko/.vscode/extensions/redhat.java-1.11.0-darwin-x64/jre/17.0.4.1-macosx-x86_64"

@depressiveRobot
Copy link

depressiveRobot commented Oct 1, 2022

@BoykoAlex

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:

/opt/homebrew/Cellar/openjdk@17/17.0.4.1_1/libexec/openjdk.jdk/Contents/Home/bin/java

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:

"java.completion.guessMethodArguments": true,
"java.codeGeneration.generateComments": true,
"spring-boot.ls.java.vmargs": [
    "-Xlog:disable"
],
"java.configuration.updateBuildConfiguration": "interactive",
"java.dependency.syncWithFolderExplorer": false,
"java.completion.favoriteStaticMembers": [
    "org.assertj.core.api.Assertions.*",
    "org.hamcrest.Matchers.*",
    "org.junit.jupiter.api.Assertions.*",
    "org.junit.jupiter.api.Assumptions.*",
    "org.junit.jupiter.api.DynamicContainer.*",
    "org.junit.jupiter.api.DynamicTest.*",
    "org.mockito.ArgumentMatchers.*",
    "org.mockito.Mockito.*",
    "org.mockito.ArgumentMatchers.*",
    "org.mockito.Answers.*",
    "org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*",
    "org.springframework.test.web.servlet.result.MockMvcResultMatchers.*"
],
"java.codeGeneration.hashCodeEquals.useJava7Objects": true,
"[java]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
}

Update

I have installed another version of the extension that doesn't ship a JRE:

.vscode-oss/extensions/redhat.java-1.11.0-universal/

By the way, I'm using a MacBook Air M1. Maybe that could play a role.

@BoykoAlex
Copy link
Contributor

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:

/opt/homebrew/Cellar/openjdk@11/11.0.16.1_1/libexec/openjdk.jdk/Contents/Home/bin/java

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...

  1. Clone sts4 git repo.
  2. Open `vscode-extensions/vscode-spring-boot folder in VSCode
  3. Ensure that terminal in vscode has java home set to java 11 to run the build.
  4. Run npm install then run ./build.sh
  5. Press F5 to launch runtime VSCode
  6. Open your spring boot project in the runtime VSCode then open a java file from the project.
  7. Observe the error. It should point at vscode-spring-boot/node_modules/vscode-jsonrpc/lin/common/... somewhere.
  8. 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: vscode something that is specific for VSCode status: needs-investigation type: bug
Projects
None yet
Development

No branches or pull requests

5 participants