vscode-java: Working Maven project reports multiple errors in VSCode and will not build

I have a simple working Java Maven project. This project builds (assuming you have Java and Maven setup) - with:

mvn clean install

And the jar file runs as expected.

However, when I open it in VSCode (I have the Java Extension pack installed) - I see 105 “Problems” reported in the pom.xml:

  • 4x “Failed to read artifact descriptor for …”
  • The rest “Missing artifact …”

This appears to prevent most of the VSCode Java tools from working - I can’t build and debug. Intellisense seems to be sketchy/intermittent. And so on.

Environment
  • Operating System: Windows 10
  • JDK version: OpenJDK 11.0.5.10
  • Visual Studio Code version: 1.41.1
  • Java extension version: 0.55.0
Steps To Reproduce
  1. Extract the attached zip file to a folder
  2. Open the folder in VSCode and inspect the Problems tab
  3. Attempt to build the project

vsc-java-test.zip

To prove Maven works
  1. Extract the attached zip file to a folder
  2. Open a bash or cmd window, cd to the folder and run mvn clean install
  3. Copy the generated thularest-1.0.jar file from <folder>/target to <folder>/bin
  4. cd to /bin and run ./rest-start.sh
  5. Crowse to http://localhost:8080/api/hello

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 11
  • Comments: 61 (8 by maintainers)

Most upvoted comments

works for me. Have you tried to execute the “Clean the Java language server workspace” command?

Same issue, my maven project is getting built but VS code is showing 1k errors.

Issue resolved update Just download lombok annotations support extension in VS Code

Tried all solutions described in this topic. From the first look, some of them worked (e.g. using java.import.generatesMetadataFilesAtProjectRoot parameter or adding java version entries into pom.xml), but when tried to reproduce from the scratch inside of a devcontainer - they didn’t work.

A working solution which resolves “missing artifacts” consistently:

  1. Run mvn clean install first
  2. Once it completes - delete workspaceStorage folder
  3. Reload window

This triggers “Java Projects” tab rebuild and all “Missing artifacts” errors are going away.

I think intermittently working methods described above worked only because they are triggering the same behavior (cleaning workspaceStorage folder), but not all the time. So it’s better to do it explicitly.

Note: the new method described here: https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting (Java: Clean the Java Language Server Workspace) doesn’t work yet, it just doesn’t trigger any actions in the devcontainer.

Important note: this only resolves “Missing artifacts” errors and population of “Java Projects” tab with entries, you may still see tons of other errors on the “Problems” tab which may be caused by your code or Java version incompatibilities and are expected.

Can we have a clean solution for this instead of doing workarounds for years?

Edit: I had similar issue with java language service 1.4.0 so I downgraded to v1.3.0 which resolved my issue.

This was the working solution for me: https://qjuanp.dev/post/vscode-java-maven-configuration-error I had to add:

"java.configuration.maven.userSettings": "/home/tdauth/.m2/settings.xml"

to my .vscode/settings.json in my cloned repository folder. I am shocked that vscode does not use this file by default.

We have a couple of private repositories with custom SSL certificates and a custom artifactory etc.

I have a similar issue, though I am compiling with bazel, not maven. Since bazel uses maven artifacts, I assume it can be the same underlying issue. If I run “Java: Clean Java Language Server Workspace” I get many compile errors from dependencies, it seems like the jdt plugin attempts to compile all source jars?

However, I have found a possible workaround: Running “Developer: Reload Window” removes all of the errors from external artifacts, and compilation works again.

@alantango no that solution did not work for me. I have now downgraded Language support for Java ™ by Red Hat to version 0.55.1. No compilation errors are now reported. There was some change done in v0.56.0 which is causing issues with legacy maven projects with multiple modules and submodules.

@manishbhalshankar I believe the solution that resolved #1365 would work for you too. Suggest you give it a try.