emacs-lsp / lsp-java

lsp-mode :heart: java
https://emacs-lsp.github.io/lsp-java
GNU General Public License v3.0
652 stars 90 forks source link

Code completions not working #183

Open delucca opened 4 years ago

delucca commented 4 years ago

I have a legacy project that I need to work on, the folder structure of the project is like the following:

<root>
  <...other files>
  implementation
    <...other projects>
    business
      src
         ...
      .project
      pom.xml
    .project
    pom.xml

If I open the project on the root of it, I was unable to even start lsp. If I open business as my root folder, I can initialize lsp correctly, but the code completion wont work.

Can anybody help me?

yyoncho commented 4 years ago

Can you provide more details? What does unable to start lsp means? What java version does the project use (JDT LS supports 8+)?

delucca commented 4 years ago

Unable to start lsp means that I cannot run any lsp command, neither autocomplete or other features works.

The project uses OpenJDK 8

sei40kr commented 4 years ago

@yyoncho I'm having same issue. I tried delete jdt.ls at once and reinstall but got no success.

java -version

openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)

jdtls:stderr

OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.gradle.internal.reflect.JavaMethod (file:/Users/sei40kr/.gradle/wrapper/dists/gradle-2.3-all/w01pvxy5gty3tegjrai84pm3/gradle-2.3/lib/gradle-base-services-2.3.jar) to method java.lang.ClassLoader.getPackages()
WARNING: Please consider reporting this to the maintainers of org.gradle.internal.reflect.JavaMethod
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

^ this may have nothing to do with

yyoncho commented 4 years ago

Hm, I haven't tested with JDK 13 - it may need special adjustments - is this a requirement for you? Did you try to delete the workspace as well?

sei40kr commented 4 years ago

@yyoncho

Did you try to delete the workspace as well?

I tried and then noticed there're no workspace cache in the directory. (there only exists 2 empty directories)

~/.emacs.d/.local/etc/java-workspace
  jdt.ls-java-project/
    bin/
    src/

lsp-java-workspace-dir is /Users/sei40kr/.emacs.d/.local/etc/java-workspace. lsp-java-workspace-cache-dir is /Users/sei40kr/.emacs.d/.local/etc/java-workspace/.cache/.

sei40kr commented 4 years ago

Also I tried OpenJDK11 and OpenJDK12 (installed with Homebrew) and it didn't work with them too.

yyoncho commented 4 years ago

Can you provide the client-server logs? Also, what kind of project do you test with? Does it work fine with hello world application like this: https://github.com/emacs-lsp/dap-mode/tree/master/features/fixtures/test-project (if you clone the repo, make sure you pick the proper root in the import project dialog).

sei40kr commented 4 years ago

@yyoncho Sorry I don't know how to change the logging verbosity. I didn't get anything on jdtls buffer with default verbosity.

I tested the hello world project above and it worked fine.

The project is https://github.com/VaughnVernon/IDDD_Samples. It uses Gradle.

yyoncho commented 4 years ago

@sei40kr I checked the content of *lsp-log* and there is the following:

Feb 16, 2020, 12:02:52 PM Synchronize Gradle projects with workspace failed due to an error connecting to the Gradle build.
Support for builds using Gradle versions older than 2.6 was removed in tooling API version 5.0. You are currently using Gradle version 2.3. You should upgrade your Gradle build to use Gradle 2.6 or later.
org.gradle.tooling.UnsupportedVersionException: Support for builds using Gradle versions older than 2.6 was removed in tooling API version 5.0. You are currently using Gradle version 2.3. You should upgrade your Gradle build to use Gradle 2.6 or later.
    at org.gradle.tooling.internal.consumer.connection.UnsupportedOlderVersionConnection.unsupported(UnsupportedOlderVersionConnection.java:83)
sei40kr commented 4 years ago

@yyoncho Sorry, I haven't seen lsp-log and there was a same error as you. And it seems the gradlew in the project uses Gradle 2.3.

I removed it and retried, then I got another error:

Details ``` Feb 16, 2020, 7:16:27 PM Synchronize project IDDD_Samples failed due to an error connecting to the Gradle build. Could not fetch model of type 'BuildEnvironment' using Gradle distribution 'https://services.gradle.org/distributions-snapshots/gradle-6.0-20191016123526+0000-bin.zip'. org.gradle.tooling.GradleConnectionException: Could not fetch model of type 'BuildEnvironment' using Gradle distribution 'https://services.gradle.org/distributions-snapshots/gradle-6.0-20191016123526+0000-bin.zip'. at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:55) at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29) at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:43) at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:62) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.base/java.lang.Thread.run(Thread.java:830) at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46) at org.gradle.tooling.internal.consumer.DefaultModelBuilder.get(DefaultModelBuilder.java:51) at org.gradle.tooling.internal.consumer.DefaultProjectConnection.getModel(DefaultProjectConnection.java:43) at org.eclipse.buildship.core.internal.util.gradle.CompatProjectConnection.getModel(CompatProjectConnection.java:51) at org.eclipse.buildship.core.internal.util.gradle.IdeAttachedProjectConnection.configureOperation(IdeAttachedProjectConnection.java:65) at org.eclipse.buildship.core.internal.util.gradle.IdeAttachedProjectConnection.model(IdeAttachedProjectConnection.java:56) at org.eclipse.buildship.core.internal.util.gradle.IdeAttachedProjectConnection.getModel(IdeAttachedProjectConnection.java:83) at org.eclipse.buildship.core.internal.workspace.EclipseModelUtils.runTasksAndQueryModels(EclipseModelUtils.java:56) at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider.lambda$null$4(DefaultModelProvider.java:75) at org.eclipse.buildship.core.internal.DefaultGradleBuild$GradleConnectionOperation.runInToolingApi(DefaultGradleBuild.java:329) at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager$WorkspaceRunnableAdapter.run(DefaultToolingApiOperationManager.java:58) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2317) at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:39) at org.eclipse.buildship.core.internal.DefaultGradleBuild.withConnection(DefaultGradleBuild.java:122) at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider.lambda$fetchEclipseProjectAndRunSyncTasks$5(DefaultModelProvider.java:75) at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4878) at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3529) at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2278) at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2155) at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2045) at com.google.common.cache.LocalCache.get(LocalCache.java:3953) at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4873) at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider.getFromCache(DefaultModelProvider.java:98) at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider.executeOperation(DefaultModelProvider.java:90) at org.eclipse.buildship.core.internal.workspace.DefaultModelProvider.fetchEclipseProjectAndRunSyncTasks(DefaultModelProvider.java:72) at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.runInToolingApi(DefaultGradleBuild.java:226) at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager$WorkspaceRunnableAdapter.run(DefaultToolingApiOperationManager.java:58) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2317) at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:39) at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.run(DefaultGradleBuild.java:192) at org.eclipse.buildship.core.internal.DefaultGradleBuild.synchronize(DefaultGradleBuild.java:100) at org.eclipse.buildship.core.internal.workspace.SynchronizationJob.runInToolingApi(SynchronizationJob.java:64) at org.eclipse.buildship.core.internal.workspace.SynchronizationJob.runInToolingApi(SynchronizationJob.java:30) at org.eclipse.buildship.core.internal.operation.ToolingApiJob$1.runInToolingApi(ToolingApiJob.java:54) at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager$WorkspaceRunnableAdapter.run(DefaultToolingApiOperationManager.java:58) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2317) at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:39) at org.eclipse.buildship.core.internal.operation.ToolingApiJob.run(ToolingApiJob.java:65) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: java.lang.IllegalArgumentException: The specified Gradle distribution 'https://services.gradle.org/distributions-snapshots/gradle-6.0-20191016123526+0000-bin.zip' does not exist. at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution.getToolingImplementationClasspath(DistributionFactory.java:137) at org.gradle.tooling.internal.consumer.loader.CachingToolingImplementationLoader.create(CachingToolingImplementationLoader.java:41) at org.gradle.tooling.internal.consumer.loader.SynchronizedToolingImplementationLoader.create(SynchronizedToolingImplementationLoader.java:44) at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.onStartAction(LazyConsumerActionExecutor.java:104) at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:86) at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45) at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:61) at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38) at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:60) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.base/java.lang.Thread.run(Thread.java:830) Caused by: java.io.FileNotFoundException: https://downloads.gradle-dn.com/distributions-snapshots/gradle-6.0-20191016123526+0000-bin.zip at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1915) at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1515) at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224) at org.gradle.wrapper.Download.downloadInternal(Download.java:78) at org.gradle.wrapper.Download.download(Download.java:63) at org.gradle.tooling.internal.consumer.DistributionInstaller$1.run(DistributionInstaller.java:128) ```
yyoncho commented 4 years ago

@sei40kr I have limited understanding about server internals - so if you get an error like that the best place to ask is in the JDT LS repo.