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

Errors in workspace until opening all source files with lombok annotations #23

Open
eif3lnerd opened this issue May 24, 2019 · 19 comments

Comments

@eif3lnerd
Copy link

Opening a project that has several files using lombok annotations will result in many errors displayed in the "Problems" tab.
Clicking on one of the errors, which opens the file will resolve the errors for that file. Once each file with lombok annotations was opened, the "Problems" tab does not show errors anymore.
Unfortunately, closing VC Code and reopening the project brings all errors back.

@vludax
Copy link

vludax commented May 29, 2019

I'm experiencing the same issue. I wonder if there would be a way to load lombok extension before the redhat.java extension.

Perhaps something like this could help: microsoft/vscode#46846

@jswxwxf
Copy link

jswxwxf commented May 30, 2019

Having the same issue. When will it be resolved?

@GabrielBB
Copy link
Contributor

GabrielBB commented Jun 3, 2019

Which Java version are you using? It happens using Maven or Gradle?

@jswxwxf
Copy link

jswxwxf commented Jun 3, 2019

I'm using java version "1.8.0_212" and Gradle 5.4.1.

@eif3lnerd
Copy link
Author

eif3lnerd commented Jun 3, 2019

openjdk version "12.0.1" 2019-04-16
OpenJDK Runtime Environment (build 12.0.1+12)
OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
Maven

@ghost
Copy link

ghost commented Jun 3, 2019

Also happening for me with

openjdk version "12.0.1" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.1+12)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12.0.1+12, mixed mode, sharing)

Using Maven

On Windows 10

@alexcjcd
Copy link

This may be a solution: https://github.com/redhat-developer/vscode-java/wiki/Lombok-support

At least for me, adding "-Xbootclasspath/a:/path/to/lombok.jar" to the java.jdt.ls.vmargs made VSCode properly load everything.

@xxbeanxx
Copy link

Adding -Xbootclasspath/a:/path/to/lombok.jar did not fix this issue for me. I still have to open each source file to get the errors to disappear.

For large projects with many classes, this makes vscode practically unusable for me.

@GKilm
Copy link

GKilm commented Aug 3, 2019

Adding -Xbootclasspath/a:/path/to/lombok.jar did not fix this issue for me. I still have to open each source file to get the errors to disappear.

For large projects with many classes, this makes vscode practically unusable for me.

It‘s same to me.I added -Xbootclasspath/a:/path/to/lombok.jar to the java.jdt.ls.vmargs in the setting file,but it didn't work properly for the opened project while VSCode was reloaded.

The solution is removing the .vscode folder for me.Hope to help you.

@xxbeanxx
Copy link

xxbeanxx commented Aug 4, 2019

Thank you @GKilm, your suggestion to delete the .vscode folder worked like a charm!

@mateusz-bajorek
Copy link

Similar:

$ ./gradlew -version

------------------------------------------------------------
Gradle 5.1.1
------------------------------------------------------------

Build time:   2019-01-10 23:05:02 UTC
Revision:     3c9abb645fb83932c44e8610642393ad62116807

Kotlin DSL:   1.1.1
Kotlin:       1.3.11
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_202 (Oracle Corporation 25.202-b08)
OS:           Mac OS X 10.14.6 x86_64

Adding -Xbootclasspath/a:/path/to/lombok.jar didn't work for me either and strangely, I have no .vscode directory in my project.

@angelov-todor
Copy link

angelov-todor commented Aug 22, 2019

Same issue here.
For me the solution was to save the open folder as new workspace.
It worked for one project only. After re- opening the workspace it start showing the errors again.

@raykr
Copy link

raykr commented Sep 17, 2019

It seems like that three projects has loading in my workspace before installing the Lombok plugin. I remove it and add it back again, this problem is vanished.

@GabrielBB
Copy link
Contributor

Please make sure you’re using the latest version of Lombok in your Pom or gradle file to avoid conflicts with the plugin

@mattiaforc
Copy link

mattiaforc commented Mar 25, 2020

I had this problem too, all the Java files using Lombok used to give the same error (i.e. The method setXXX is undefined for the type YYY). I never had a .vscode folder in my project.

This may be a solution: https://github.com/redhat-developer/vscode-java/wiki/Lombok-support

At least for me, adding "-Xbootclasspath/a:/path/to/lombok.jar" to the java.jdt.ls.vmargs made VSCode properly load everything.

This fixed it - I'll leave my specs below anyway so that anyone can try to replicate the environment and see if it works out for them too.
Beware that -Xbootclasspath/a:/path/to/lombok.jar has to be escaped with \" like -Xbootclasspath\"/a:/path/to/lombok.jar\" otherwise it wont' work (it can be pretty obvious but I spent some time figuring this out).

EDIT: I noticed that placing the -Xbootclasspath flag made VS Code not work properly on other java projects in other directories as well, being unable to show compiler errors and even unable to run due to a Could not find or load main class exception. I did not manage to find a workaround for this problem yet; in fact, if the flag -Xbootclasspath/a:/path/to/lombok.jar is present in the VS Code settings other projects won't work. It's quite annoying to have to insert and remove that line while working on different projects. I always used Java: clean the language server workspace every time I closed/opened VS Code.

@GabrielBB maybe you could export -Xbootclasspath\"/a:/path/to/lombok.jar\" as a default option in the plugin? Pointing at -Xbootclasspath\"/a:/home/USER/.vscode/extensions/gabrielbb.vscode-lombok-1.0.1/server/lombok.jar\"

Lombok version in build.gradle: org.projectlombok:lombok:1.18.12
Gradle wrapper version:

$ ./gradlew --version
------------------------------------------------------------
Gradle 6.3-rc-4
------------------------------------------------------------

Build time:   2020-03-20 05:39:45 UTC
Revision:     507eaa2e999827ec256a700ffc413c5e92a9e69d

Kotlin:       1.3.70
Groovy:       2.5.10
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          13.0.2 (Oracle Corporation 13.0.2+8)
OS:           Linux 5.3.0-42-generic amd64

@rafaelrenanpacheco
Copy link

Based on @GKilm suggestion to delete the .vscode folder, which I think don't exists anymore, I deleted all VS Code generated folders and files:

  • .settings/
  • .classpath
  • .factorypath
  • .project

After that I opened VS Code and the lombok issues where gone. Then I closed and opened again 5x times to make sure, and the issue didn't come back.

@LangInteger
Copy link

Based on @GKilm suggestion to delete the .vscode folder, which I think don't exists anymore, I deleted all VS Code generated folders and files:

  • .settings/
  • .classpath
  • .factorypath
  • .project

After that I opened VS Code and the lombok issues where gone. Then I closed and opened again 5x times to make sure, and the issue didn't come back.

This works just great for me!

@EuniceB
Copy link

EuniceB commented Jul 13, 2020

Based on @GKilm suggestion to delete the .vscode folder, which I think don't exists anymore, I deleted all VS Code generated folders and files:

* .settings/

* .classpath

* .factorypath

* .project

After that I opened VS Code and the lombok issues where gone. Then I closed and opened again 5x times to make sure, and the issue didn't come back.

I tried this but as soon as I compiled the project using maven, the lombok errors were back.

@EuniceB
Copy link

EuniceB commented Jun 11, 2021

It's been almost a year, no fix yet? What I have to do every time I compile the project is to go to the pom.xml file and remove the scope from the lombok dependency, save the file, add the scope again. The errors disappear. This is a very hacky solution and we shouldn't have to mess around to get it to work.

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.20</version>
    <scope>compile</scope> <-- I remove the "compile", save the file, add it again
</dependency>

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