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

lsp-java doesn't detect core libraries on Apple M3 macbook air #478

Open JoshTRN opened 5 months ago

JoshTRN commented 5 months ago

Describe the bug The workspace fails to detect java core libraries and doesn't work on Apple M3 air.

Note

To Reproduce On Apple M3 macbook air:

Expected behavior All the standard library and dependencies should be detected and all the standard lsp-java apis should function normally.

Screenshots image

Logs

May 30, 2024, 4:27:28 PM ProjectRegistryRefreshJob finished 29774ms
May 30, 2024, 4:27:28 PM Started org.eclipse.buildship.core 0ms
Creating watchers for following 19 folders:
  /Users/joshua/code/demo
  /Users/joshua/code/demo/.settings
  /Users/joshua/code/demo/bin
  /Users/joshua/code/demo/bin/main
  /Users/joshua/code/demo/bin/test
  /Users/joshua/code/demo/gradle
  /Users/joshua/code/demo/gradle/wrapper
  /Users/joshua/code/demo/src
  /Users/joshua/code/demo/src/main
  /Users/joshua/code/demo/src/main/java
  /Users/joshua/code/demo/src/main/java/com
  /Users/joshua/code/demo/src/main/java/com/example
  /Users/joshua/code/demo/src/main/java/com/example/demo
  /Users/joshua/code/demo/src/main/resources
  /Users/joshua/code/demo/src/test
  /Users/joshua/code/demo/src/test/java
  /Users/joshua/code/demo/src/test/java/com
  /Users/joshua/code/demo/src/test/java/com/example
  /Users/joshua/code/demo/src/test/java/com/example/demo
This server does not support foldingRangeProvider
May 30, 2024, 4:27:28 PM >> initialized
Init...[Starting]
0% Starting Java Language Server[Starting]
May 30, 2024, 4:27:29 PM RepositoryRegistryUpdateJob finished 0ms
May 30, 2024, 4:27:29 PM Project configurator 'org.eclipse.buildship.configurators.base' failed to configure project 'demo'
Cannot convert string value 'VERSION_21' to an enum value of type 'org.gradle.api.JavaVersion' (valid case insensitive values: VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_1_9, VERSION_1_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_HIGHER)
java.lang.IllegalArgumentException: Cannot convert string value 'VERSION_21' to an enum value of type 'org.gradle.api.JavaVersion' (valid case insensitive values: VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_1_9, VERSION_1_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_HIGHER)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.toEnum(ProtocolToModelAdapter.java:204)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.adaptToEnum(ProtocolToModelAdapter.java:177)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.createView(ProtocolToModelAdapter.java:146)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.convert(ProtocolToModelAdapter.java:276)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.access$1500(ProtocolToModelAdapter.java:56)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$AdaptingMethodInvoker.invoke(ProtocolToModelAdapter.java:477)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$PropertyCachingMethodInvoker.invoke(ProtocolToModelAdapter.java:705)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$SafeMethodInvoker.invoke(ProtocolToModelAdapter.java:742)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$SupportedPropertyInvoker.invoke(ProtocolToModelAdapter.java:766)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$InvocationHandlerImpl.invoke(ProtocolToModelAdapter.java:432)
    at jdk.proxy8/jdk.proxy8.$Proxy64.getSourceLanguageLevel(Unknown Source)
    at org.eclipse.buildship.core.internal.util.gradle.CompatSourceSettings.getSourceLanguageLevel(CompatSourceSettings.java:42)
    at org.eclipse.buildship.core.internal.workspace.JavaSourceSettingsUpdater.update(JavaSourceSettingsUpdater.java:37)
    at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.synchronizeJavaProjectInTransaction(BaseConfigurator.java:119)
    at org.eclipse.buildship.core.internal.workspace.BaseConfigurator$1.run(BaseConfigurator.java:105)
    at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:41)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:740)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407)
    at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5961)
    at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5918)
    at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.synchronizeJavaProject(BaseConfigurator.java:101)
    at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.configure(BaseConfigurator.java:91)
    at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.configure(BaseConfigurator.java:66)
    at org.eclipse.buildship.core.internal.extension.InternalProjectConfigurator.configure(InternalProjectConfigurator.java:65)
    at org.eclipse.buildship.core.internal.workspace.ProjectConfigurators.configureConfigurators(ProjectConfigurators.java:70)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeOpenWorkspaceProject(SynchronizeGradleBuildOperation.java:163)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeWorkspaceProject(SynchronizeGradleBuildOperation.java:137)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:127)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:85)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2402)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeProjectsWithWorkspace(SynchronizeGradleBuildOperation.java:82)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:64)
    at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.runInToolingApi(DefaultGradleBuild.java:232)
    at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager$WorkspaceRunnableAdapter.run(DefaultToolingApiOperationManager.java:58)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407)
    at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:39)
    at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.run(DefaultGradleBuild.java:194)
    at org.eclipse.buildship.core.internal.DefaultGradleBuild.synchronize(DefaultGradleBuild.java:102)
    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:2382)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407)
    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)

May 30, 2024, 4:27:29 PM Synchronize Gradle projects with workspace failed due to an unexpected error.
Cannot convert string value 'VERSION_21' to an enum value of type 'org.gradle.api.JavaVersion' (valid case insensitive values: VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_1_9, VERSION_1_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_HIGHER)
java.lang.IllegalArgumentException: Cannot convert string value 'VERSION_21' to an enum value of type 'org.gradle.api.JavaVersion' (valid case insensitive values: VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_1_9, VERSION_1_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_HIGHER)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.toEnum(ProtocolToModelAdapter.java:204)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.adaptToEnum(ProtocolToModelAdapter.java:177)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.createView(ProtocolToModelAdapter.java:146)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.convert(ProtocolToModelAdapter.java:276)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.access$1500(ProtocolToModelAdapter.java:56)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$AdaptingMethodInvoker.invoke(ProtocolToModelAdapter.java:477)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$PropertyCachingMethodInvoker.invoke(ProtocolToModelAdapter.java:705)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$SafeMethodInvoker.invoke(ProtocolToModelAdapter.java:742)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$SupportedPropertyInvoker.invoke(ProtocolToModelAdapter.java:766)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$InvocationHandlerImpl.invoke(ProtocolToModelAdapter.java:432)
    at jdk.proxy8/jdk.proxy8.$Proxy64.getSourceLanguageLevel(Unknown Source)
    at org.eclipse.buildship.core.internal.util.gradle.CompatSourceSettings.getSourceLanguageLevel(CompatSourceSettings.java:42)
    at org.eclipse.buildship.core.internal.workspace.JavaSourceSettingsUpdater.update(JavaSourceSettingsUpdater.java:37)
    at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.synchronizeJavaProjectInTransaction(BaseConfigurator.java:119)
    at org.eclipse.buildship.core.internal.workspace.BaseConfigurator$1.run(BaseConfigurator.java:105)
    at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:41)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:740)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407)
    at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5961)
    at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5918)
    at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.synchronizeJavaProject(BaseConfigurator.java:101)
    at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.configure(BaseConfigurator.java:91)
    at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.configure(BaseConfigurator.java:66)
    at org.eclipse.buildship.core.internal.extension.InternalProjectConfigurator.configure(InternalProjectConfigurator.java:65)
    at org.eclipse.buildship.core.internal.workspace.ProjectConfigurators.configureConfigurators(ProjectConfigurators.java:70)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeOpenWorkspaceProject(SynchronizeGradleBuildOperation.java:163)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeWorkspaceProject(SynchronizeGradleBuildOperation.java:137)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:127)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:85)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2402)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeProjectsWithWorkspace(SynchronizeGradleBuildOperation.java:82)
    at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:64)
    at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.runInToolingApi(DefaultGradleBuild.java:232)
    at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager$WorkspaceRunnableAdapter.run(DefaultToolingApiOperationManager.java:58)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407)
    at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:39)
    at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.run(DefaultGradleBuild.java:194)
    at org.eclipse.buildship.core.internal.DefaultGradleBuild.synchronize(DefaultGradleBuild.java:102)
    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:2382)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407)
    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)

May 30, 2024, 4:27:29 PM Initialization failed 
jdt.ls-java-project does not exist
Java Model Exception: Error in Java Model (code 969): jdt.ls-java-project does not exist
    at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:584)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:254)
    at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:597)
    at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:328)
    at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:314)
    at org.eclipse.jdt.internal.core.JavaElement.getChildren(JavaElement.java:269)
    at org.eclipse.jdt.internal.core.JavaProject.getPackageFragmentRoots(JavaProject.java:2384)
    at org.eclipse.jdt.internal.core.JavaProject.getPackageFragments(JavaProject.java:2408)
    at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.cleanupResources(ProjectsManager.java:280)
    at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:108)
    at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:257)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

jdt.ls-java-project does not exist[Error]
20% Starting Java Language Server[Starting]
May 30, 2024, 4:27:29 PM >> initialization job finished
May 30, 2024, 4:27:29 PM >> registerWatchers'
May 30, 2024, 4:27:29 PM >> registerFeature 'workspace/didChangeWatchedFiles'
May 30, 2024, 4:27:29 PM Failed to build workspace.
jdt.ls-java-project does not exist
Java Model Exception: Error in Java Model (code 969): jdt.ls-java-project does not exist
    at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:584)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:254)
    at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:597)
    at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:328)
    at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:314)
    at org.eclipse.jdt.internal.core.JavaElement.getChildren(JavaElement.java:269)
    at org.eclipse.jdt.internal.core.JavaProject.getPackageFragmentRoots(JavaProject.java:2384)
    at org.eclipse.jdt.internal.core.JavaProject.getPackageFragments(JavaProject.java:2408)
    at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.cleanupResources(ProjectsManager.java:280)
    at org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandler.buildWorkspace(BuildWorkspaceHandler.java:59)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$25(JDTLanguageServer.java:929)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$54(JDTLanguageServer.java:1129)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)

ServiceReady[ServiceReady]
May 30, 2024, 4:27:29 PM An internal error occurred during: "Initialize workspace".
Model not available for demo
org.eclipse.buildship.core.internal.GradlePluginsRuntimeException: Model not available for demo
    at org.eclipse.buildship.core.internal.workspace.GradleClasspathContainerRuntimeClasspathEntryResolver.resolveRuntimeClasspathEntry(GradleClasspathContainerRuntimeClasspathEntryResolver.java:82)
    at org.eclipse.buildship.core.internal.workspace.GradleClasspathContainerRuntimeClasspathEntryResolver.resolveRuntimeClasspathEntry(GradleClasspathContainerRuntimeClasspathEntryResolver.java:58)
    at org.eclipse.jdt.internal.launching.RuntimeClasspathEntryResolver.resolveRuntimeClasspathEntry(RuntimeClasspathEntryResolver.java:49)
    at org.eclipse.jdt.launching.JavaRuntime.resolveRuntimeClasspathEntry(JavaRuntime.java:1259)
    at org.eclipse.buildship.core.internal.launch.GradleClasspathProvider.resolveClasspath(GradleClasspathProvider.java:101)
    at org.eclipse.jdt.internal.launching.RuntimeClasspathProvider.resolveClasspath(RuntimeClasspathProvider.java:68)
    at org.eclipse.jdt.launching.JavaRuntime.resolveRuntimeClasspath(JavaRuntime.java:1661)
    at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.getClasspathAndModulepath(AbstractJavaLaunchConfigurationDelegate.java:464)
    at org.eclipse.jdt.ls.core.internal.commands.ProjectCommand$1.run(ProjectCommand.java:176)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407)
    at org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.getClasspathsFromJavaProject(ProjectCommand.java:173)
    at org.eclipse.jdt.ls.core.internal.preferences.Preferences.getAnnotationType(Preferences.java:2296)
    at org.eclipse.jdt.ls.core.internal.preferences.Preferences.hasAnnotationNullAnalysisTypes(Preferences.java:2284)
    at org.eclipse.jdt.ls.core.internal.preferences.Preferences.updateAnnotationNullAnalysisOptions(Preferences.java:2219)
    at org.eclipse.jdt.ls.core.internal.managers.StandardProjectsManager.projectsImported(StandardProjectsManager.java:649)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer$2.run(JDTLanguageServer.java:307)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
AnonymusBadger commented 3 months ago

Hi! I'm facing similar issue. @JoshTRN Ware you able to resolve this?

Describe the bug

The workspace fails to detect java core libraries and dependencies. With lsp-java-configuration-runtimes The type java.lang.Object... goes away and I get some completion working for java core (I still get the error in log), but not for dependencies e.g. The import org.junit cannot be resolved

Note

Jul 30, 2024, 1:17:34 PM Synchronize Gradle projects with workspace failed due to an unexpected error. Cannot convert string value 'VERSION_21' to an enum value of type 'org.gradle.api.JavaVersion' (valid case insensitive values: VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_1_9, VERSION_1_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_HIGHER) java.lang.IllegalArgumentException: Cannot convert string value 'VERSION_21' to an enum value of type 'org.gradle.api.JavaVersion' (valid case insensitive values: VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_1_9, VERSION_1_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_HIGHER) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.toEnum(ProtocolToModelAdapter.java:204) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.adaptToEnum(ProtocolToModelAdapter.java:177) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.createView(ProtocolToModelAdapter.java:146) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.convert(ProtocolToModelAdapter.java:276) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.access$1500(ProtocolToModelAdapter.java:56) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$AdaptingMethodInvoker.invoke(ProtocolToModelAdapter.java:477) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$PropertyCachingMethodInvoker.invoke(ProtocolToModelAdapter.java:705) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$SafeMethodInvoker.invoke(ProtocolToModelAdapter.java:742) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$SupportedPropertyInvoker.invoke(ProtocolToModelAdapter.java:766) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$InvocationHandlerImpl.invoke(ProtocolToModelAdapter.java:432) at jdk.proxy8/jdk.proxy8.$Proxy66.getSourceLanguageLevel(Unknown Source) at org.eclipse.buildship.core.internal.util.gradle.CompatSourceSettings.getSourceLanguageLevel(CompatSourceSettings.java:42) at org.eclipse.buildship.core.internal.workspace.JavaSourceSettingsUpdater.update(JavaSourceSettingsUpdater.java:37) at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.synchronizeJavaProjectInTransaction(BaseConfigurator.java:119) at org.eclipse.buildship.core.internal.workspace.BaseConfigurator$1.run(BaseConfigurator.java:105) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:41) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:740) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5961) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5918) at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.synchronizeJavaProject(BaseConfigurator.java:101) at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.configure(BaseConfigurator.java:91) at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.configure(BaseConfigurator.java:66) at org.eclipse.buildship.core.internal.extension.InternalProjectConfigurator.configure(InternalProjectConfigurator.java:65) at org.eclipse.buildship.core.internal.workspace.ProjectConfigurators.configureConfigurators(ProjectConfigurators.java:70) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeOpenWorkspaceProject(SynchronizeGradleBuildOperation.java:163) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeWorkspaceProject(SynchronizeGradleBuildOperation.java:137) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:127) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:85) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2402) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeProjectsWithWorkspace(SynchronizeGradleBuildOperation.java:82) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:64) at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.runInToolingApi(DefaultGradleBuild.java:232) at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager$WorkspaceRunnableAdapter.run(DefaultToolingApiOperationManager.java:58) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407) at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:39) at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.run(DefaultGradleBuild.java:194) at org.eclipse.buildship.core.internal.DefaultGradleBuild.synchronize(DefaultGradleBuild.java:102) 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:2382) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407) 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)

Jul 30, 2024, 1:17:34 PM >> initialized Init...[Starting] 0% Starting Java Language Server[Starting] Jul 30, 2024, 1:17:34 PM RepositoryRegistryUpdateJob finished 0ms Jul 30, 2024, 1:17:34 PM Importing Gradle project(s) Jul 30, 2024, 1:17:34 PM Test was modified since last time the workspace was opened, must be synchronized 55% Starting Java Language Server[Starting] Jul 30, 2024, 1:17:38 PM Project configurator 'org.eclipse.buildship.configurators.base' failed to configure project 'app' Cannot convert string value 'VERSION_21' to an enum value of type 'org.gradle.api.JavaVersion' (valid case insensitive values: VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_1_9, VERSION_1_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_HIGHER) java.lang.IllegalArgumentException: Cannot convert string value 'VERSION_21' to an enum value of type 'org.gradle.api.JavaVersion' (valid case insensitive values: VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_1_9, VERSION_1_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_HIGHER) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.toEnum(ProtocolToModelAdapter.java:204) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.adaptToEnum(ProtocolToModelAdapter.java:177) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.createView(ProtocolToModelAdapter.java:146) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.convert(ProtocolToModelAdapter.java:276) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter.access$1500(ProtocolToModelAdapter.java:56) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$AdaptingMethodInvoker.invoke(ProtocolToModelAdapter.java:477) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$PropertyCachingMethodInvoker.invoke(ProtocolToModelAdapter.java:705) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$SafeMethodInvoker.invoke(ProtocolToModelAdapter.java:742) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$SupportedPropertyInvoker.invoke(ProtocolToModelAdapter.java:766) at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$InvocationHandlerImpl.invoke(ProtocolToModelAdapter.java:432) at jdk.proxy8/jdk.proxy8.$Proxy66.getSourceLanguageLevel(Unknown Source) at org.eclipse.buildship.core.internal.util.gradle.CompatSourceSettings.getSourceLanguageLevel(CompatSourceSettings.java:42) at org.eclipse.buildship.core.internal.workspace.JavaSourceSettingsUpdater.update(JavaSourceSettingsUpdater.java:37) at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.synchronizeJavaProjectInTransaction(BaseConfigurator.java:119) at org.eclipse.buildship.core.internal.workspace.BaseConfigurator$1.run(BaseConfigurator.java:105) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:41) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:740) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5961) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5918) at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.synchronizeJavaProject(BaseConfigurator.java:101) at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.configure(BaseConfigurator.java:91) at org.eclipse.buildship.core.internal.workspace.BaseConfigurator.configure(BaseConfigurator.java:66) at org.eclipse.buildship.core.internal.extension.InternalProjectConfigurator.configure(InternalProjectConfigurator.java:65) at org.eclipse.buildship.core.internal.workspace.ProjectConfigurators.configureConfigurators(ProjectConfigurators.java:70) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeOpenWorkspaceProject(SynchronizeGradleBuildOperation.java:163) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeWorkspaceProject(SynchronizeGradleBuildOperation.java:137) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:127) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:85) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2402) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.synchronizeProjectsWithWorkspace(SynchronizeGradleBuildOperation.java:82) at org.eclipse.buildship.core.internal.workspace.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:64) at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.runInToolingApi(DefaultGradleBuild.java:232) at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager$WorkspaceRunnableAdapter.run(DefaultToolingApiOperationManager.java:58) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407) at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:39) at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.run(DefaultGradleBuild.java:194) at org.eclipse.buildship.core.internal.DefaultGradleBuild.synchronize(DefaultGradleBuild.java:102) at org.eclipse.buildship.core.internal.DefaultGradleBuild.synchronize(DefaultGradleBuild.java:88) at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.startSynchronization(GradleProjectImporter.java:409) at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.importDir(GradleProjectImporter.java:297) at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.importToWorkspace(GradleProjectImporter.java:210) at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:150) at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:112) at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:257) at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

WARNING[ProjectStatus] 100% Starting Java Language Server[Starting] Jul 30, 2024, 1:17:38 PM Workspace initialized in 4604ms Ready[Started] 100% Starting Java Language Server[Starting] Jul 30, 2024, 1:17:38 PM >> initialization job finished Jul 30, 2024, 1:17:38 PM >> registerWatchers' Jul 30, 2024, 1:17:38 PM Runtime JavaEnvironment [name=JavaSE-21, path=null, javadoc=null, sources=null] is not valid. Jul 30, 2024, 1:17:38 PM >> registerFeature 'workspace/didChangeWatchedFiles' Creating watchers for following 2 folders: /home/user/Documents/Code/sandbox/Java/Test/app/bin/main/org /home/user/Documents/Code/sandbox/Java/Test/app/bin/main/org/example Creating watchers for following 2 folders: /home/user/Documents/Code/sandbox/Java/Test/app/bin/test/org /home/user/Documents/Code/sandbox/Java/Test/app/bin/test/org/example Jul 30, 2024, 1:17:39 PM Error occured while building workspace. Details: message: Can't use Java 21 and Gradle 8.9 to import Gradle project Test.; code: 0; resource: /home/user/Documents/Code/sandbox/Java/Test; line: 1 message: Project configurator 'org.eclipse.buildship.configurators.base' failed to configure project 'app'; code: 0; resource: /home/user/Documents/Code/sandbox/Java/Test/app; message: The import org.junit cannot be resolved; code: 268435846; resource: /home/user/Documents/Code/sandbox/Java/Test/app/src/test/java/org/example/AppTest.java; line: 6 message: The import org.junit cannot be resolved; code: 268435846; resource: /home/user/Documents/Code/sandbox/Java/Test/app/src/test/java/org/example/AppTest.java; line: 8 message: Test cannot be resolved to a type; code: 16777218; resource: /home/user/Documents/Code/sandbox/Java/Test/app/src/test/java/org/example/AppTest.java; line: 11 message: The method assertNotNull(String, String) is undefined for the type AppTest; code: 67108964; resource: /home/user/Documents/Code/sandbox/Java/Test/app/src/test/java/org/example/AppTest.java; line: 14 ServiceReady[ServiceReady] Jul 30, 2024, 1:17:39 PM An internal error occurred during: "Initialize workspace". Model not available for app org.eclipse.buildship.core.internal.GradlePluginsRuntimeException: Model not available for app at org.eclipse.buildship.core.internal.workspace.GradleClasspathContainerRuntimeClasspathEntryResolver.resolveRuntimeClasspathEntry(GradleClasspathContainerRuntimeClasspathEntryResolver.java:82) at org.eclipse.buildship.core.internal.workspace.GradleClasspathContainerRuntimeClasspathEntryResolver.resolveRuntimeClasspathEntry(GradleClasspathContainerRuntimeClasspathEntryResolver.java:58) at org.eclipse.jdt.internal.launching.RuntimeClasspathEntryResolver.resolveRuntimeClasspathEntry(RuntimeClasspathEntryResolver.java:49) at org.eclipse.jdt.launching.JavaRuntime.resolveRuntimeClasspathEntry(JavaRuntime.java:1259) at org.eclipse.buildship.core.internal.launch.GradleClasspathProvider.resolveClasspath(GradleClasspathProvider.java:101) at org.eclipse.jdt.internal.launching.RuntimeClasspathProvider.resolveClasspath(RuntimeClasspathProvider.java:68) at org.eclipse.jdt.launching.JavaRuntime.resolveRuntimeClasspath(JavaRuntime.java:1661) at org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.getClasspathAndModulepath(AbstractJavaLaunchConfigurationDelegate.java:464) at org.eclipse.jdt.ls.core.internal.commands.ProjectCommand$1.run(ProjectCommand.java:176) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2382) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2407) at org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.getClasspathsFromJavaProject(ProjectCommand.java:173) at org.eclipse.jdt.ls.core.internal.preferences.Preferences.getAnnotationType(Preferences.java:2296) at org.eclipse.jdt.ls.core.internal.preferences.Preferences.hasAnnotationNullAnalysisTypes(Preferences.java:2284) at org.eclipse.jdt.ls.core.internal.preferences.Preferences.updateAnnotationNullAnalysisOptions(Preferences.java:2219) at org.eclipse.jdt.ls.core.internal.managers.StandardProjectsManager.projectsImported(StandardProjectsManager.java:649) at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer$2.run(JDTLanguageServer.java:307) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

100% Starting Java Language Server[Starting] 100% Starting Java Language Server - Synchronize Gradle project app with workspace project[Starting] 100% Starting Java Language Server[Starting]

AnonymusBadger commented 3 months ago

I've managed to fix it!

Setting lsp-java-jdt-download-url to https://www.eclipse.org/downloads/download.php?file=/jdtls/milestones/1.37.0/jdt-language-server-1.37.0-202406271335.tar.gz (latest jdtls release as of today (30.07.2024) fixed the issue.

The default jdtls in lsp-java is 1.26 which is older than JDK 21 release date.

'(lsp-java-jdt-download-url
   "https://www.eclipse.org/downloads/download.php?file=/jdtls/milestones/1.37.0/jdt-language-server-1.37.0-202406271335.tar.gz")
shaneikennedy commented 2 months ago

@AnonymusBadger worked for me, thanks for this!

samuelhnrq-pivot commented 2 months ago

I've just spent a million years trying to fix the error related to java version, just to find out it was an old JDT-ls version 🤦 for the fellow noobs who might be struggling: