Vscode-java: VSCode fails to load pom packaged parent of a multi-module maven project

Created on 22 Jan 2021  路  5Comments  路  Source: redhat-developer/vscode-java

Even a simple multi-module maven project where the top level pom has <packaging>pom</packaging> will fail with the pom packaged project not being loaded and then the language server failing with the following:

[Error - 2:23:52 PM] Jan 22, 2021, 2:23:52 PM Problem load project library 
maven-multi-example does not exist
Java Model Exception: Java Model Status [maven-multi-example does not exist]
    at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:573)
    at org.eclipse.jdt.internal.core.JavaModelManager.getPerProjectInfoCheckExistence(JavaModelManager.java:2525)
    at org.eclipse.jdt.internal.core.JavaProject.getPerProjectInfo(JavaProject.java:2382)
    at org.eclipse.jdt.internal.core.JavaProject.getRawClasspath(JavaProject.java:2411)
    at com.microsoft.jdtls.ext.core.PackageCommand.getContainers(PackageCommand.java:258)
    at com.microsoft.jdtls.ext.core.PackageCommand.getChildren(PackageCommand.java:107)
    at com.microsoft.jdtls.ext.core.CommandHandler.executeCommand(CommandHandler.java:31)
    at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:215)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:205)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$3(JDTLanguageServer.java:497)
    at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Environment
  • Operating System: MacOS Big Sur
  • JDK version: 15.0.1
  • Visual Studio Code version: 1.52.1
  • Java extension version: v0.74.0
Steps To Reproduce
  1. Clone this example project: https://github.com/chadlyon/maven-multi-example.git
  2. code maven-multi-example
Current Result
Expected Result
Additional Informations

Changing to jar packaging produces the expected behavior in VSCode but results in a maven error.

Most helpful comment

Fixed in downstream

All 5 comments

Actually, looking deeper, even switching to jar packaging does not fully load the Java project. It gets a little further and loads the JRE Library and Maven Dependencies for each sub-module but packages and classes do NOT show up under the modules in "Java Projects". It seems multi-module maven projects are broken in VSCode.

Update: Adding <nature>org.eclipse.jdt.core.javanature</nature> to the top level .project file under natures and then refreshing the project fixes everything.

I suppose this should have been fixed by Java Project Explorer. https://github.com/microsoft/vscode-java-dependency/issues/424

@jdneo could you help verify whether this issue still exists in multi-module maven projects?

The project manager does not handle the multi-module project properly. Raised a PR to fix this issue: https://github.com/microsoft/vscode-java-dependency/pull/450

Fixed in downstream

Was this page helpful?
0 / 5 - 0 ratings