vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Extension never activates, throwing error "Header must provide a Content-Length property"

Open atcericandrews opened this issue 3 years ago • 15 comments

As per the title, the extension never activates; the java language server status never switches to the thumbs-up. The extension runtime status shows 37 copies of the same uncaught error: Header must provide a Content-Length property. The developer tools logs show the same error, slightly more verbosely:

workbench.desktop.main.js:2272 Error: Header must provide a Content-Length property.
	at p.onData (c:\Users\Eric.Andrews\.vscode\extensions\redhat.java-1.8.0-win32-x64\dist\extension.js:2:1138205)
	at Socket.<anonymous> (c:\Users\Eric.Andrews\.vscode\extensions\redhat.java-1.8.0-win32-x64\dist\extension.js:2:1137926)
	at Socket.emit (node:events:390:28)
	at addChunk (node:internal/streams/readable:315:12)
	at readableAddChunk (node:internal/streams/readable:289:9)
	at Socket.Readable.push (node:internal/streams/readable:228:10)
	at Pipe.onStreamRead (node:internal/stream_base_commons:199:23)
Environment
  • Operating System: Windows 10 Enterprise (10.0.19044)
  • JDK version: Eclipse Adoptium 17.0.3.7-hotspot
  • Visual Studio Code version: 1.69.2
  • Java extension version: 1.8.0
Steps To Reproduce
  1. Install jdk and VSCode
  2. Install the Extension Pack for Java
  3. Update settings.json to point to jdk: "java.jdt.ls.java.home": "C:\\Program Files\\Eclipse Adoptium\\jdk-17.0.3.7-hotspot"
  4. Open any .java file

language server logs dev tools console logs

atcericandrews avatar Jul 19 '22 15:07 atcericandrews

same issue on:

VS code versions 1.68.1 and 1.67.0 RedHat Java extension 1.7.0, 1.8.0, 1.90 (multiple combinations of the above were tried, all had same issue)

JDK version 11.0.12 (oracle)

i hope this is fixed soon because i straight up cannot work on java properly in vs code right now

devin-lo avatar Jul 25 '22 19:07 devin-lo

Seems to be similar to #2292

elizalde1981 avatar Jul 26 '22 18:07 elizalde1981

same issue here, out of the blue it just stopped working.

Operating System: Windows 10 Enterprise (10.0.19044) JDK version: tried a couple all through JAVE_HOME; Oracle 11.0.15 , OpenJDK 17 (Oracle / Redhat / MS) Visual Studio Code version: 1.69.2 Java extension version: v1.9.0

mainThreadExtensionService.ts:79 [[object Object]]Header must provide a Content-Length property.
$onExtensionRuntimeError @ mainThreadExtensionService.ts:79
mainThreadExtensionService.ts:80 Error: Header must provide a Content-Length property.
	at p.onData (c:\Users\LeeVic\.vscode\extensions\redhat.java-1.9.0-win32-x64\dist\extension.js:2:1052283)
	at Socket.<anonymous> (c:\Users\LeeVic\.vscode\extensions\redhat.java-1.9.0-win32-x64\dist\extension.js:2:1052004)
	at Socket.emit (node:events:390:28)
	at addChunk (node:internal/streams/readable:315:12)
	at readableAddChunk (node:internal/streams/readable:289:9)
	at Socket.Readable.push (node:internal/streams/readable:228:10)
	at Pipe.onStreamRead (node:internal/stream_base_commons:199:23)

victorlee0505 avatar Jul 27 '22 01:07 victorlee0505

Also happening to me. Its very annoying. I have to switch to Eclipse for now image

Foxhunter981 avatar Aug 08 '22 22:08 Foxhunter981

In my case, adding -Xlog:jni+resolve=off to java.jdt.ls.vmargs solved this problem.

languageclient has receiving rpc response with error messages as follows.

[0.158s][warning][jni,resolve] Re-registering of platform native method: java.lang.PanwHooks.NativeMethodEntry(Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V from code in a different classloader
Content-Length: 780

PanwHooks seems to be related to Palo Alto Networks products, which this product seems to injecting DLLs into the JVM.

muchida6 avatar Aug 09 '22 05:08 muchida6

@muchida6 I am also facing the same issue. Getting same warning with Javac -version command in cmd as well. Can you bit more specific where to add the vmargs. I tried to add in vscode settings.json. But no luck.

sudheerkkumar avatar Aug 09 '22 06:08 sudheerkkumar

I'm getting the same error. The workaround given by @muchida6 worked for me. @sudheerkkumar To add this config line you have to go to Setting and type java.jdt.ls.vmargs and click Edit in settings.json. image

MarcSerret51 avatar Aug 09 '22 07:08 MarcSerret51

Thanks @MarcSerret51 . It is working now.

sudheerkkumar avatar Aug 09 '22 08:08 sudheerkkumar

@muchida6 thanks for finding that out. Where did you see the "Re-registering of platform native method: java.lang.PanwHooks.NativeMethodEntry" response? in some logs or while debugging vscode?

fbricon avatar Aug 09 '22 09:08 fbricon

I would also like to know where this response was found. I didn't see it locally but that could just mean I missed an important debug step

Foxhunter981 avatar Aug 09 '22 12:08 Foxhunter981

@muchida6 Great Thanks!! btw, now junit test stuck at resolving launch config from debugger for java extension, but I can live with that :-D

victorlee0505 avatar Aug 09 '22 15:08 victorlee0505

@fbricon @Foxhunter981 I was just trying to debug. image

muchida6 avatar Aug 09 '22 23:08 muchida6

@victorlee0505 Running the junit test by vscode-java-test worked for me, though vscode-java-test has vmArgs in java.test.config (https://github.com/Microsoft/vscode-java-test/wiki/Run-with-Configuration), so adding -Xlog:jni+resolve=off might work better. I hope this helps.

muchida6 avatar Aug 09 '22 23:08 muchida6

i added these 2 enties in setting.json to make test runner and springboot dashboard works!

"java.debug.settings.vmArgs": "-Xlog:jni+resolve=off",
"spring-boot.ls.java.vmargs": ["-Xlog:jni+resolve=off"],

victorlee0505 avatar Aug 10 '22 13:08 victorlee0505

@muchida6 thank's dude it's working on me :)

jundiaufa11 avatar Aug 11 '22 05:08 jundiaufa11

@muchida6 I spent so many hours trying to figure this out. Your solution was the answer. Thank you so much!

jgriffin1 avatar Aug 11 '22 19:08 jgriffin1

I'm not having this specific problem, but the related problem mentioned here https://github.com/redhat-developer/vscode-java/issues/2623

Regardless, VS Code is basically the equivalent of notepad on windows for me, until this is fixed.

ghost avatar Aug 17 '22 15:08 ghost

@jmihalichuber could you, please, attach your logs - Enable Logging

snjeza avatar Aug 17 '22 18:08 snjeza

Hi Joe @jmihalichuber Did you find any solution i am also stuck, i tried the workaround it is not working.?

Does installing another version will help ?

shivamfet avatar Aug 22 '22 15:08 shivamfet