Theia: Error downloading Java language server

Created on 4 Jul 2018  ยท  12Comments  ยท  Source: eclipse-theia/theia

When pulling the current (2018-07-04 15:27) sources I get an error when starting Theia in the browser. This happens when I create a Java file and the Java language server starts. Following error is printed:

languages ERROR Error occurred while starting language contribution. /services/languages/java. Error: The Java server launcher is not found. at JavaContribution.start (/home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/java/lib/node/java-contribution.js:58:19) at /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/languages/lib/node/languages-backend-contribution.js:51:34 at /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/lib/node/messaging/messaging-contribution.js:100:13 at /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/lib/node/messaging/messaging-contribution.js:237:17 at ConnectionHandlers.route (/home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/lib/node/messaging/messaging-contribution.js:247:38) at WebSocket.<anonymous> (/home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/lib/node/messaging/messaging-contribution.js:141:43) at emitOne (events.js:116:13) at WebSocket.emit (events.js:211:7) at Receiver._receiver.onmessage (/home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/node_modules/ws/lib/WebSocket.js:141:47) at Receiver.dataMessage (/home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/node_modules/ws/lib/Receiver.js:389:14) root ERROR Error: The Java server launcher is not found. at JavaContribution.start (/home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/java/lib/node/java-contribution.js:58:19) at /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/languages/lib/node/languages-backend-contribution.js:51:34 at /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/lib/node/messaging/messaging-contribution.js:100:13 at /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/lib/node/messaging/messaging-contribution.js:237:17 at ConnectionHandlers.route (/home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/lib/node/messaging/messaging-contribution.js:247:38) at WebSocket.<anonymous> (/home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/lib/node/messaging/messaging-contribution.js:141:43) at emitOne (events.js:116:13) at WebSocket.emit (events.js:211:7) at Receiver._receiver.onmessage (/home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/node_modules/ws/lib/WebSocket.js:141:47) at Receiver.dataMessage (/home/jlburot/Dokumente/Recherchen/Theia/theia/theia/packages/core/node_modules/ws/lib/Receiver.js:389:14) root ERROR Cannot find a service for the path: /services/languages/java

I checked /packages/java/download/ for what Theia downloads. The found file is che-jdt-language-server-latest.tar.gz. Also, I expected a gulp-file, but I guess that file has been taken out at some point during the past month or so. Still, some of the Java language server features seem to work, like the context menu popping up when hitting Ctrl+Space in the code.

Anyway, is there a fix for the mentioned error message? Is this known?

bug java

All 12 comments

Hi @jeanlucburot! Can you check the /packages/java/server directory, is there something? After downloading the tar.gz it's supposed to be unzipped into that directory.

Also, were there any errors reported during the installation? Could you retry, but first rm -rf node_modules and rm -rf /packages/java/download?

Hi @AlexTugarev !
I forgot to mention the following:

OS: Ubuntu 16.04
yarn: 1.7.0
npm: 6.0.1
node: 8.11.3

So I did as you asked:

rm -rf packages/java/download/
rm -rf node_modules/
yarn

I then get the following error:

yarn install v1.7.0
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
warning [email protected]: The engine "vscode" appears to be invalid.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
warning "workspace-aggregator-bd7f7a52-f257-4040-889c-33b2f55fff8e > @theia/application-manager > [email protected]" has unmet peer dependency "font-awesome@>=4.3.0".
[5/5] Building fresh packages...
[-/10] โ ‚ waiting...
[-/10] โ ‚ waiting...
[-/10] โ ‚ waiting...
[-/10] โ ‚ waiting...
error /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/node_modules/@theia/java: Command failed.
Exit code: 1
Command: node ./scripts/download-jdt-ls.js
Arguments:
Directory: /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/node_modules/@theia/java

Then I hit the following and everything runs through smoothly.

yarn

And nope, in /packages/java/server there is nothing. The tree is the following:

โ”œโ”€โ”€ compile.tsconfig.json
โ”œโ”€โ”€ data
โ”‚   โ”œโ”€โ”€ javadoc.tmlanguage.json
โ”‚   โ””โ”€โ”€ java.tmlanguage.json
โ”œโ”€โ”€ download
โ”‚   โ””โ”€โ”€ che-jdt-language-server-latest.tar.gz
โ”œโ”€โ”€ lib
โ”‚   โ”œโ”€โ”€ browser
โ”‚   โ”‚   โ”œโ”€โ”€ index.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ index.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ index.js
โ”‚   โ”‚   โ”œโ”€โ”€ index.js.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-client-contribution.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ java-client-contribution.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-client-contribution.js
โ”‚   โ”‚   โ”œโ”€โ”€ java-client-contribution.js.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-commands.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ java-commands.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-commands.js
โ”‚   โ”‚   โ”œโ”€โ”€ java-commands.js.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-frontend-module.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ java-frontend-module.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-frontend-module.js
โ”‚   โ”‚   โ”œโ”€โ”€ java-frontend-module.js.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-keybinding-contexts.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ java-keybinding-contexts.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-keybinding-contexts.js
โ”‚   โ”‚   โ”œโ”€โ”€ java-keybinding-contexts.js.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-label-provider.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ java-label-provider.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-label-provider.js
โ”‚   โ”‚   โ”œโ”€โ”€ java-label-provider.js.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-protocol.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ java-protocol.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-protocol.js
โ”‚   โ”‚   โ”œโ”€โ”€ java-protocol.js.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-resource.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ java-resource.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-resource.js
โ”‚   โ”‚   โ”œโ”€โ”€ java-resource.js.map
โ”‚   โ”‚   โ””โ”€โ”€ monaco-contribution
โ”‚   โ”‚       โ”œโ”€โ”€ index.d.ts
โ”‚   โ”‚       โ”œโ”€โ”€ index.d.ts.map
โ”‚   โ”‚       โ”œโ”€โ”€ index.js
โ”‚   โ”‚       โ”œโ”€โ”€ index.js.map
โ”‚   โ”‚       โ”œโ”€โ”€ java-monaco-language.d.ts
โ”‚   โ”‚       โ”œโ”€โ”€ java-monaco-language.d.ts.map
โ”‚   โ”‚       โ”œโ”€โ”€ java-monaco-language.js
โ”‚   โ”‚       โ”œโ”€โ”€ java-monaco-language.js.map
โ”‚   โ”‚       โ”œโ”€โ”€ java-textmate-contribution.d.ts
โ”‚   โ”‚       โ”œโ”€โ”€ java-textmate-contribution.d.ts.map
โ”‚   โ”‚       โ”œโ”€โ”€ java-textmate-contribution.js
โ”‚   โ”‚       โ””โ”€โ”€ java-textmate-contribution.js.map
โ”‚   โ”œโ”€โ”€ common
โ”‚   โ”‚   โ”œโ”€โ”€ index.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ index.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ index.js
โ”‚   โ”‚   โ””โ”€โ”€ index.js.map
โ”‚   โ”œโ”€โ”€ node
โ”‚   โ”‚   โ”œโ”€โ”€ index.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ index.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ index.js
โ”‚   โ”‚   โ”œโ”€โ”€ index.js.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-backend-module.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ java-backend-module.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-backend-module.js
โ”‚   โ”‚   โ”œโ”€โ”€ java-backend-module.js.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-contribution.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ java-contribution.d.ts.map
โ”‚   โ”‚   โ”œโ”€โ”€ java-contribution.js
โ”‚   โ”‚   โ””โ”€โ”€ java-contribution.js.map
โ”‚   โ”œโ”€โ”€ package.spec.d.ts
โ”‚   โ”œโ”€โ”€ package.spec.d.ts.map
โ”‚   โ”œโ”€โ”€ package.spec.js
โ”‚   โ””โ”€โ”€ package.spec.js.map
โ”œโ”€โ”€ node_modules
โ”‚   โ””โ”€โ”€ tar
โ”‚       โ”œโ”€โ”€ index.js
โ”‚       โ”œโ”€โ”€ lib
โ”‚       โ”‚   โ”œโ”€โ”€ buffer.js
โ”‚       โ”‚   โ”œโ”€โ”€ create.js
โ”‚       โ”‚   โ”œโ”€โ”€ extract.js
โ”‚       โ”‚   โ”œโ”€โ”€ header.js
โ”‚       โ”‚   โ”œโ”€โ”€ high-level-opt.js
โ”‚       โ”‚   โ”œโ”€โ”€ large-numbers.js
โ”‚       โ”‚   โ”œโ”€โ”€ list.js
โ”‚       โ”‚   โ”œโ”€โ”€ mkdir.js
โ”‚       โ”‚   โ”œโ”€โ”€ mode-fix.js
โ”‚       โ”‚   โ”œโ”€โ”€ pack.js
โ”‚       โ”‚   โ”œโ”€โ”€ parse.js
โ”‚       โ”‚   โ”œโ”€โ”€ pax.js
โ”‚       โ”‚   โ”œโ”€โ”€ read-entry.js
โ”‚       โ”‚   โ”œโ”€โ”€ replace.js
โ”‚       โ”‚   โ”œโ”€โ”€ types.js
โ”‚       โ”‚   โ”œโ”€โ”€ unpack.js
โ”‚       โ”‚   โ”œโ”€โ”€ update.js
โ”‚       โ”‚   โ”œโ”€โ”€ warn-mixin.js
โ”‚       โ”‚   โ”œโ”€โ”€ winchars.js
โ”‚       โ”‚   โ””โ”€โ”€ write-entry.js
โ”‚       โ”œโ”€โ”€ LICENSE
โ”‚       โ”œโ”€โ”€ node_modules
โ”‚       โ”œโ”€โ”€ package.json
โ”‚       โ””โ”€โ”€ README.md
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ scripts
โ”‚   โ”œโ”€โ”€ download-jdt-ls.js
โ”‚   โ”œโ”€โ”€ get-dev-server.js
โ”‚   โ”œโ”€โ”€ pom.xml
โ”‚   โ””โ”€โ”€ shared.js
โ”œโ”€โ”€ server
โ””โ”€โ”€ src
    โ”œโ”€โ”€ browser
    โ”‚   โ”œโ”€โ”€ index.ts
    โ”‚   โ”œโ”€โ”€ java-client-contribution.ts
    โ”‚   โ”œโ”€โ”€ java-commands.ts
    โ”‚   โ”œโ”€โ”€ java-frontend-module.ts
    โ”‚   โ”œโ”€โ”€ java-keybinding-contexts.ts
    โ”‚   โ”œโ”€โ”€ java-label-provider.ts
    โ”‚   โ”œโ”€โ”€ java-protocol.ts
    โ”‚   โ”œโ”€โ”€ java-resource.ts
    โ”‚   โ””โ”€โ”€ monaco-contribution
    โ”‚       โ”œโ”€โ”€ index.ts
    โ”‚       โ”œโ”€โ”€ java-monaco-language.ts
    โ”‚       โ””โ”€โ”€ java-textmate-contribution.ts
    โ”œโ”€โ”€ common
    โ”‚   โ””โ”€โ”€ index.ts
    โ”œโ”€โ”€ node
    โ”‚   โ”œโ”€โ”€ index.ts
    โ”‚   โ”œโ”€โ”€ java-backend-module.ts
    โ”‚   โ””โ”€โ”€ java-contribution.ts
    โ””โ”€โ”€ package.spec.ts

Then I hit the following and everything runs through smoothly.

That's a false positive. I'd consider this to be a bug, as it just checks if the downloaded file exists, but it doesn't verify the unpacked files.

We need to understand, why this happens:

error /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/node_modules/@theia/java: Command failed.
Exit code: 1

Could your try again with yarn install --verbose > output.txt and try find some anything relevant near to Command: node ./scripts/download-jdt-ls.js? Of course this requires the removal of node_modules and packages/java/download first. Thanks!

Did the command.

yarn install --verbose

It all comes down to an HTTP 400 error when trying to download

verbose 16.555 Error: /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/node_modules/@theia/java: Command failed.
Exit code: 1
Command: node ./scripts/download-jdt-ls.js
Arguments: 
Directory: /home/jlburot/Dokumente/Recherchen/Theia/theia/theia/node_modules/@theia/java
Output:
redirect location: http://mirror.switch.ch/eclipse/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz
failed to download with code: 400
    at ProcessTermError.ExtendableBuiltin (/usr/share/yarn/lib/cli.js:243:66)
    at ProcessTermError.MessageError (/usr/share/yarn/lib/cli.js:272:123)
    at new ProcessTermError (/usr/share/yarn/lib/cli.js:312:113)
    at ChildProcess.<anonymous> (/usr/share/yarn/lib/cli.js:30299:17)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

In the file /packages/java/scripts/download-jdt-ls.js are these three lines:

const serverPath = packageJson['ls.download.path'] || '/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz';
const downloadURI = packageJson['ls.download.base'] || 'https://www.eclipse.org/downloads/download.php?file=';
const archiveUri = downloadURI + serverPath + '&r=1';

The constant archiveUri is the path to the file to be downloaded, ending up as a parameter for a download method within the same file:

downloadWithRedirect(archiveUri);

The created path is:

 https://www.eclipse.org/downloads/download.php?file=/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz&r=1

Typing this in the browser (Chrome) works well, but when trying to download this using wget, the download blocks with the message:

Lรคnge: nicht spezifiziert [text/html]

translating to:

Length: not specified [text/html]

The eclipse.org server seems to send a URL redirect, hence the same method downloadWithRedirect() is called again with the new url which is:

http://mirror.switch.ch/eclipse/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz

Downloading the file using this URL works well in both the browser and using wget. Now, the constant statusCode though is not too happy, responding here with a 400, ending in with the file.destroy(); command.

So, this is the point until I get. I can't quite figure out, why the downloadWithRedirect() method runs into a response.statusCode 400, even though the URL works perfectly fine typed manually into the browser or wget.

For test purposes I created a local server with the language server for download, setting

archiveUri = "http://localhost:8080/che-jdt-language-server-latest.tar.gz";

The tar.gz is now downloaded and saved into the packages/java/download/ folder. Though there still is the following error when running ``:

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: incorrect header check
    at Gunzip.zlibOnError (zlib.js:153:15)

Nothing is unzipped into the packages/java/server folder. I checked the archive and I seems ok and I can unzip it.

I tested around with this issue this weekend on Ubuntu 18.04, Ubuntu 16.04, Linux Mint 19, Debian 9, and Fedora 28 from home where I don't have to use a proxy. With a bit of configuration here and there, I eventually got it running on all of those systems. The Java language server works like a charm. Now, being back at work I tried the same stuff where I have to use a proxy, and I fail doing so. I can't get Theia to download from http://mirror.switch.ch/eclipse/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz due to an HTTP 400 error (400 Bad Request).

From the IETF 6.5.1. 400 Bad Request:

The 400 (Bad Request) status code indicates that the server cannot or
will not process the request due to something that is perceived to be
a client error (e.g., malformed request syntax, invalid request
message framing, or deceptive request routing).

So I checked within Theia and it all comes back to the file packages/java/scripts/download-jdt-ls.js and within that file specifically the command h.get(url, response => {...}).
Within that function const statusCode = response.statusCode; returns 400.

So I tried setting the proxy manually. I set the proxy for npm and Node:

npm config set proxy http://webproxy.mycompany.com:8000
npm config set https-proxy https://webproxy.mycompany.com:8000

I also set the proxy for bash:

export http_proxy=http://webproxy.mycompany.com:8000
export https_proxy=https://webproxy.mycompany.com:8000

Also for yarn:

yarn config set proxy http://webproxy.mycompany.com:8000
yarn config set https-proxy https://webproxy.mycompany.com:8000

But the problem is still the same. I still get HTTP 400. Downloading the file in the browser (Chrome) works perfectly. Downloading the file using wget http://mirror.switch.ch/eclipse/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz works perfectly. Downloading the file using curl http://mirror.switch.ch/eclipse/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz --output che-jdt-language-server-latest.tar.gz works perfectly.

So @AlexTugarev suggested, that the problem could possibly be due to the custom download script not considering the proxy settings from Yarn or ENV. The GET request in the custom download script does not set anything.

I tried to set the download url directly to circumnavigate the redirect call. I opened

theia/packages/java/scripts/download-jdt-ls.js

and set archiveUri directly to the redirect Url given by

https://www.eclipse.org/downloads/download.php?file=/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz&r=1

, which is

http://mirror.switch.ch/eclipse/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz

. Now I don't enter the redirect, but the error still is failed to download with code: 400, hence HTTP 400. My test to download the file with

wget http://mirror.switch.ch/eclipse/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz

is successful.

@jeanlucburot I would try to extend the download script to use proxy settings, which should be available as env vars in node (process.env.HTTP_PROXY and process.env.HTTPS_PROXY).

This would require to rewrite the get call here.

Maybe you want to work on this?

Edit:
http.request should be used instead of the convenient get call.

@AlexTugarev I already had a failed attempt at http.request. Possible reason for that were the missing env vars. I will try again and post a message here.

While this truly is a bug, I sadly cannot reproduce the case, as there have been changes with the proxy server within my company and now running the exact same Java language server download script does exactly what it is expected to do. No errors, no blocks. Hence, I would close this issue, but am happy to reopen it upon request.
Thanks.

We get the following error in several CI systems including theia PR appveyor: https://ci.appveyor.com/project/kittaakos/theia/builds/24909469

Successfully downloaded Java LS
Decompressing the archive to C:\projects\theia\packages\java\server.
events.js:174
      throw er; // Unhandled 'error' event
      ^
Error: incorrect header check
    at Zlib.zlibOnError [as onerror] (zlib.js:154:17)
Emitted 'error' event at:
    at Gunzip.onerror (_stream_readable.js:713:12)
    at Gunzip.emit (events.js:189:13)
    at Zlib.zlibOnError [as onerror] (zlib.js:157:8)
Was this page helpful?
0 / 5 - 0 ratings