eclipse-jdtls / eclipse.jdt.ls

Java language server
1.79k stars 399 forks source link

Classpath is incomplete when opening maven project #1320

Open pbogren opened 4 years ago

pbogren commented 4 years ago

I am using the server from archlinux AUR through LanguageClient-neovim.

When I open a maven project I see that the project root is set correctly to the project root which contains a pom.xml file. But diagnostics and go to definition is not working and when checking the jdtls log I see the Classpath is incomplete. Only syntax errors will be reported message.

The command to invoke jdtls from vim is

/usr/bin/jdtls -data getcwd()

And this is /usr/bin/jdtls from the AUR package with my addition for jdk 9 support

#!/bin/bash

# copy the configuration folder to tmp to be writable
tmp_dir="$(mktemp -d /tmp/jdtls.XXXXX)"
cp -R /usr/share/java/jdtls/config_linux "${tmp_dir}"
# and ensure that it is removed on exit
trap "{ rm -rf ${tmp_dir}; }" EXIT

java \
    -Declipse.application=org.eclipse.jdt.ls.core.id1 \
    -Dosgi.bundles.defaultStartLevel=4 \
    -Declipse.product=org.eclipse.jdt.ls.core.product \
    -noverify \
    -Xms1G \
    -jar /usr/share/java/jdtls/plugins/org.eclipse.equinox.launcher_*.jar \
    -configuration "${tmp_dir}/config_linux" \
    --add-modules=ALL-SYSTEM \
    --add-opens java.base/java.util=ALL-UNNAMED \
    --add-opens java.base/java.lang=ALL-UNNAMED \
    "$@"

I have tried removing the jdt.ls-java-project and .metadata directories but it didn't help.

matt-snider commented 4 years ago

@mmFooD I was able to fix this by changing -data to point to some generic location and not the project directory. I think using getcwd() is incorrect. Setting it to -data $HOME/.local/share/jdt-language-server for example, worked for me