Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JoshTRN opened this issue May 30, 2024 · 4 comments
Open

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

JoshTRN opened this issue May 30, 2024 · 4 comments

Comments

@JoshTRN
Copy link
Contributor

JoshTRN commented May 30, 2024

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

Note

  • I'm using spacemacs with the java layer which installs lsp-java
  • Here's my java -version output:
openjdk version "21.0.3" 2024-04-16
OpenJDK Runtime Environment Homebrew (build 21.0.3)
OpenJDK 64-Bit Server VM Homebrew (build 21.0.3, mixed mode, sharing)
  • This works in vscode and the java extension pack

To Reproduce
On Apple M3 macbook air:

  • install latest jdk from homebrew brew install java(this should install 21.0.3)
  • start fresh spring project through spring initializer using all the defaults and java 21
  • enter the DemoApplication.java
  • I also set the lsp-java-configuration-runtimes
  (setq lsp-java-configuration-runtimes '[(:name "JavaSE-21"
                                      :path "/opt/homebrew/Cellar/openjdk/21.0.3/libexec/openjdk.jdk/Contents/Home"
                                      :default t)])

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
Copy link

AnonymusBadger commented Jul 30, 2024

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

  • I'm using Doom Emacs on Arch Linux with the (java +lsp +tree-sitter) module
  • java --version installed with jabba:
openjdk 21.0.2 2024-01-16
OpenJDK Runtime Environment (build 21.0.2+13-58)
OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)
  • I have lsp-workspace-folder root set to same dir as where gradle init was run

To Reproduce

  1. Install [email protected] with jabba
  2. Initialize new Gradle 8.9 Application project with defaults (JUnit Juniper for testing)
  3. Open example App.java or AppTest.java
  4. Custom lsp-java-configuration-runtimes:
(after! lsp-java
  (setq lsp-java-java-path (concat (getenv "JAVA_HOME") "/bin/java"))
  (setq lsp-java-configuration-runtimes `[
                                          (:name "JavaSE-21"
                                           :path ,(getenv "JAVA_HOME")
                                           :default t)]))
  1. .envrc:
PATH_add ~/.jabba/jdk/[email protected]
JAVA_HOME=~/.jabba/jdk/[email protected]

Logs

Jul 30, 2024, 1:17:33 PM ProjectRegistryRefreshJob finished 29621ms
Jul 30, 2024, 1:17:33 PM Started org.eclipse.buildship.core 0ms
Creating watchers for following 61 folders:
  /home/user/Documents/Code/sandbox/Java/Test
  /home/user/Documents/Code/sandbox/Java/Test/.settings
  /home/user/Documents/Code/sandbox/Java/Test/app
  /home/user/Documents/Code/sandbox/Java/Test/app/.settings
  /home/user/Documents/Code/sandbox/Java/Test/app/bin
  /home/user/Documents/Code/sandbox/Java/Test/app/bin/main
  /home/user/Documents/Code/sandbox/Java/Test/app/bin/main/org
  /home/user/Documents/Code/sandbox/Java/Test/app/bin/main/org/example
  /home/user/Documents/Code/sandbox/Java/Test/app/bin/test
  /home/user/Documents/Code/sandbox/Java/Test/app/bin/test/org
  /home/user/Documents/Code/sandbox/Java/Test/app/bin/test/org/example
  /home/user/Documents/Code/sandbox/Java/Test/app/build
  /home/user/Documents/Code/sandbox/Java/Test/app/build/classes
  /home/user/Documents/Code/sandbox/Java/Test/app/build/classes/java
  /home/user/Documents/Code/sandbox/Java/Test/app/build/classes/java/main
  /home/user/Documents/Code/sandbox/Java/Test/app/build/classes/java/main/org
  /home/user/Documents/Code/sandbox/Java/Test/app/build/classes/java/main/org/example
  /home/user/Documents/Code/sandbox/Java/Test/app/build/classes/java/test
  /home/user/Documents/Code/sandbox/Java/Test/app/build/classes/java/test/org
  /home/user/Documents/Code/sandbox/Java/Test/app/build/classes/java/test/org/example
  /home/user/Documents/Code/sandbox/Java/Test/app/build/distributions
  /home/user/Documents/Code/sandbox/Java/Test/app/build/generated
  /home/user/Documents/Code/sandbox/Java/Test/app/build/generated/sources
  /home/user/Documents/Code/sandbox/Java/Test/app/build/generated/sources/annotationProcessor
  /home/user/Documents/Code/sandbox/Java/Test/app/build/generated/sources/annotationProcessor/java
  /home/user/Documents/Code/sandbox/Java/Test/app/build/generated/sources/annotationProcessor/java/main
  /home/user/Documents/Code/sandbox/Java/Test/app/build/generated/sources/annotationProcessor/java/test
  /home/user/Documents/Code/sandbox/Java/Test/app/build/generated/sources/headers
  /home/user/Documents/Code/sandbox/Java/Test/app/build/generated/sources/headers/java
  /home/user/Documents/Code/sandbox/Java/Test/app/build/generated/sources/headers/java/main
  /home/user/Documents/Code/sandbox/Java/Test/app/build/generated/sources/headers/java/test
  /home/user/Documents/Code/sandbox/Java/Test/app/build/libs
  /home/user/Documents/Code/sandbox/Java/Test/app/build/reports
  /home/user/Documents/Code/sandbox/Java/Test/app/build/reports/tests
  /home/user/Documents/Code/sandbox/Java/Test/app/build/reports/tests/test
  /home/user/Documents/Code/sandbox/Java/Test/app/build/reports/tests/test/classes
  /home/user/Documents/Code/sandbox/Java/Test/app/build/reports/tests/test/css
  /home/user/Documents/Code/sandbox/Java/Test/app/build/reports/tests/test/js
  /home/user/Documents/Code/sandbox/Java/Test/app/build/reports/tests/test/packages
  /home/user/Documents/Code/sandbox/Java/Test/app/build/scripts
  /home/user/Documents/Code/sandbox/Java/Test/app/build/test-results
  /home/user/Documents/Code/sandbox/Java/Test/app/build/test-results/test
  /home/user/Documents/Code/sandbox/Java/Test/app/build/test-results/test/binary
  /home/user/Documents/Code/sandbox/Java/Test/app/build/tmp
  /home/user/Documents/Code/sandbox/Java/Test/app/build/tmp/compileJava
  /home/user/Documents/Code/sandbox/Java/Test/app/build/tmp/compileTestJava
  /home/user/Documents/Code/sandbox/Java/Test/app/build/tmp/jar
  /home/user/Documents/Code/sandbox/Java/Test/app/build/tmp/test
  /home/user/Documents/Code/sandbox/Java/Test/app/src
  /home/user/Documents/Code/sandbox/Java/Test/app/src/main
  /home/user/Documents/Code/sandbox/Java/Test/app/src/main/java
  /home/user/Documents/Code/sandbox/Java/Test/app/src/main/java/org
  /home/user/Documents/Code/sandbox/Java/Test/app/src/main/java/org/example
  /home/user/Documents/Code/sandbox/Java/Test/app/src/main/resources
  /home/user/Documents/Code/sandbox/Java/Test/app/src/test
  /home/user/Documents/Code/sandbox/Java/Test/app/src/test/java
  /home/user/Documents/Code/sandbox/Java/Test/app/src/test/java/org
  /home/user/Documents/Code/sandbox/Java/Test/app/src/test/java/org/example
  /home/user/Documents/Code/sandbox/Java/Test/app/src/test/resources
  /home/user/Documents/Code/sandbox/Java/Test/gradle
  /home/user/Documents/Code/sandbox/Java/Test/gradle/wrapper
Jul 30, 2024, 1:17:34 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.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 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
Copy link

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
Copy link

@AnonymusBadger worked for me, thanks for this!

@samuelhnrq-pivot
Copy link

samuelhnrq-pivot commented Sep 10, 2024

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:

  • You can use setq to change the value of the lsp-java-jdt-download-url
  • You can find the link to the current latest version here
  • After setting the URL dont forget to reload/config and run M-x -> lsp-update-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants