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

Possible Lombok Incompatibility #4224

Closed
aelfric opened this issue Sep 26, 2019 · 23 comments
Closed

Possible Lombok Incompatibility #4224

aelfric opened this issue Sep 26, 2019 · 23 comments
Labels
kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant

Comments

@aelfric
Copy link

aelfric commented Sep 26, 2019

Sorry if this is not really a Quarkus bug. I'm a newcommer to Quarkus working on a proof of concept. I have a project that is making some minimal use of Lombok annotations. When running mvn quarkus:dev, occasionally after modifying one of the Lombok-annotated classes and trying to refresh the browser, I get a an error with the below stacktrace.

Expected behavior
Code recompiles successfully.

Actual behavior

    Can't initialize javac processor due to (most likely) a class loader problem: java.lang.NoClassDefFoundError: com/sun/tools/javac/processing/JavacProcessingEnvironment
  	at lombok.javac.apt.LombokProcessor.getJavacProcessingEnvironment(LombokProcessor.java:410)
  	at lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:90)
  	at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:124)
  	at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:177)
  	at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:73)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:500)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:597)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:690)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
  	at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
  	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
  	at com.sun.tools.javac.main.Main.compile(Main.java:523)
  	at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
  	at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
  	at io.quarkus.dev.JavaCompilationProvider.compile(JavaCompilationProvider.java:55)
  	at io.quarkus.dev.ClassLoaderCompiler.compile(ClassLoaderCompiler.java:156)
  	at io.quarkus.dev.RuntimeUpdatesProcessor.checkForChangedClasses(RuntimeUpdatesProcessor.java:164)
  	at io.quarkus.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:103)
  	at io.quarkus.undertow.deployment.devmode.UndertowHotReplacementSetup.handleHotDeploymentRequest(UndertowHotReplacementSetup.java:72)
  	at io.quarkus.undertow.deployment.devmode.UndertowHotReplacementSetup$1$1.handleRequest(UndertowHotReplacementSetup.java:61)
  	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
  	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
  	at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:224)
  	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
  	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
  	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
  	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
  	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
  	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
  	at java.lang.Thread.run(Thread.java:748)
  	at org.jboss.threads.JBossThread.run(JBossThread.java:479)

To Reproduce
Steps to reproduce the behavior:

  1. Modify a file annotated with Lombok @Data
  2. Refresh in the brower causing the code to re-compile.

Environment (please complete the following information):

  • Output of uname -a or ver: This is on Windows 10 version 1903,
  • Output of java -version:
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b04, mixed mode)
  • GraalVM version (if different from Java): N/A
  • Quarkus version or git rev: 0.21.3

Additional context
If it matters, this is a multi-module maven project with two modules web and service. web is the quarkus module. Both web and service have a few classes using Lombok.

@aelfric aelfric added the kind/bug Something isn't working label Sep 26, 2019
@dmlloyd
Copy link
Member

dmlloyd commented Sep 26, 2019

This does seem like a real Quarkus bug. If I had to spitball some ideas, I'd say maybe inconsistent TCCL contents might be a possible culprit, or maybe an error in how we assemble the app's class loader which is probably also inconsistent with how we do it in regular mode. Maybe it varies from run to run or something.

@jaikiran
Copy link
Member

@aelfric Is there a project you can share, perhaps as a github repo, which helps reproduce this issue?

@aelfric
Copy link
Author

aelfric commented Sep 29, 2019 via email

@matus-m
Copy link

matus-m commented Oct 7, 2019

Its probably related to #1502.

@stale
Copy link

stale bot commented Nov 13, 2019

This issue/pullrequest has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 13, 2019
@maxandersen maxandersen removed the stale label Nov 13, 2019
@tobad357
Copy link

tobad357 commented Jan 7, 2020

Any luck with this as we are hitting the same issue?

@aelfric
Copy link
Author

aelfric commented Jan 7, 2020

No luck on my side. As a (albeit poor) workaround, we've resorted to minimizing use of Lombok in new code, but we have just been restarting maven whenever we make changes to older code with Lombok annotations.

@jaikiran
Copy link
Member

jaikiran commented Jan 8, 2020

Hello @tobad357, Any chance you can share a reproducer for this (maybe as a github repo with the source)?

@tobad357
Copy link

tobad357 commented Jan 8, 2020

@jaikiran please see https://github.com/tobad357/quarkus-lombok-test
To trigger the issue do the following

  1. Start quarkus dev (./gradlew quarkusDev)
  2. Edit src/main/java/org/acme/ExampleResource.java and change the log message
  3. Reload the url http://0.0.0.0:8080/hello

This will give you the error if using the following JVM

OpenJDK 64-Bit GraalVM CE 19.2.1 (build 25.232-b07-jvmci-19.2-b03, mixed mode)

It will work without issue using the following JVM
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)

@aelfric
Copy link
Author

aelfric commented Jan 8, 2020

Sorry I was never able to contribute a minimal reproducer, but this one from tobad357 is behaving the same for me as the issue we're encountering in our project. We are not using GraalVM, though. I'm running on Windows 10 with the following JVM.

openjdk version "1.8.0_212"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b04, mixed mode)

@ssindelar
Copy link

I have the same behavior with gradle on Windows. The missing Class is part of the Java Compiler.

I noticed that lombok trys to use the JRE as compiler because "Java.home" is set to the jre folder inside the jdk:

Java.home: C:\Program Files\Java\jdk8u222-b10\jre

I can't find a way to change it to the root of the JDK. Outside the lombok + Quarkus combination everything works fine and the correct path is used.

@jaikiran
Copy link
Member

Sorry, I have been a bit busy and wasn't able to look into this sooner. I will try and find some time this weekend and see what's going on and if I can help.

@tfactor2
Copy link

tfactor2 commented Feb 1, 2020

Had the same problem on OpenJDK 8 but it's gone after switching to GraalVM.

@stefanorg
Copy link

i've the same issue

@mklueh
Copy link
Contributor

mklueh commented Feb 23, 2020

I´m running into issues with Lombok too. @builder annotation for example works really unreliable, Builder classes are sometimes not created when I´m running quarkusBuild ( quarkusDev works).

Example: The decompiled code below is one entity that uses the Builder annotation. It produces the static builder() method, but not the MyClassBuilder class, which is why I´m running into
java.lang.ClassNotFoundException

@Entity
public class MyClass  extends PanacheEntity implements ManagedEntity, PersistentAttributeInterceptable, SelfDirtinessTracker {
  
  public static MyClassBuilder builder() {
    return new MyClassBuilder();
  }


  public static class MyClass {
  }
}

*What seems weird is that MyClass contains an empty static MyClass . Other entity classes that are not annotated with @builder won´t have this static class.

Getters and setters on the other hand are created as expected.

@yahmed153
Copy link

yahmed153 commented Jul 9, 2020

having the same issue, with @Log annotation, have to shutdown dev mode then restart and it works fine after that. As well the ExampleResource.class doesnt seem to reflect my src file there is only one log entry when there should be 2

Stack Trace

java.lang.RuntimeException: Compilation failed[/home/yahmed/src/hackathon-yaser/src/main/java/io/quarkus/hackathon/ExampleResource.java:13: warning: Can't initialize javac processor due to (most likely) a class loader problem: java.lang.NoClassDefFoundError: com/sun/tools/javac/processing/JavacProcessingEnvironment
public class ExampleResource {
       ^
  	at lombok.javac.apt.LombokProcessor.getJavacProcessingEnvironment(LombokProcessor.java:419)
  	at lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:90)
  	at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:124)
  	at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:177)
  	at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:73)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:508)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:605)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:698)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1043)
  	at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1184)
  	at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
  	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
  	at com.sun.tools.javac.main.Main.compile(Main.java:523)
  	at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
  	at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
  	at io.quarkus.deployment.dev.JavaCompilationProvider.compile(JavaCompilationProvider.java:69)
  	at io.quarkus.deployment.dev.ClassLoaderCompiler.compile(ClassLoaderCompiler.java:176)
  	at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.checkForChangedClasses(RuntimeUpdatesProcessor.java:250)
  	at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:160)
  	at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$1.handle(VertxHttpHotReplacementSetup.java:50)
  	at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$1.handle(VertxHttpHotReplacementSetup.java:42)
  	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
  	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
  	at java.lang.Thread.run(Thread.java:748)
  Resulted in: java.lang.ClassNotFoundException: com.sun.tools.javac.processing.JavacProcessingEnvironment
  	at java.lang.ClassLoader.findClass(ClassLoader.java:523)
  	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
  	at lombok.launch.ShadowClassLoader.loadClass(ShadowClassLoader.java:534)
  	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
  	... 27 more, /home/yahmed/src/hackathon-yaser/src/main/java/io/quarkus/hackathon/ExampleResource.java:18: error: cannot find symbol
        log.info("hello");
        ^
  symbol:   variable log
  location: class io.quarkus.hackathon.ExampleResource, /home/yahmed/src/hackathon-yaser/src/main/java/io/quarkus/hackathon/ExampleResource.java:19: error: cannot find symbol
        log.info("hello");
        ^
  symbol:   variable log
  location: class io.quarkus.hackathon.ExampleResource]
	at io.quarkus.deployment.dev.JavaCompilationProvider.compile(JavaCompilationProvider.java:70)
	at io.quarkus.deployment.dev.ClassLoaderCompiler.compile(ClassLoaderCompiler.java:176)
	at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.checkForChangedClasses(RuntimeUpdatesProcessor.java:250)
	at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:160)
	at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$1.handle(VertxHttpHotReplacementSetup.java:50)
	at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$1.handle(VertxHttpHotReplacementSetup.java:42)
	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)```

@yahmed153
Copy link

yahmed153 commented Jul 9, 2020

Also tried to use the delombok maven plugin with no success

http://anthonywhitford.com/lombok.maven/lombok-maven-plugin/usage.html

@garyhodgson
Copy link

garyhodgson commented Oct 25, 2020

Hi,

It appears that including the com.sun:tools artifact as a system scoped dependency allows lombok to function with dev mode, e.g.:

   <dependency>
      <groupId>com.sun</groupId>
      <artifactId>tools</artifactId>
      <version>1.8</version>
      <systemPath>${java.home}/../lib/tools.jar</systemPath>
      <scope>system</scope>
    </dependency>

hiding it in a dedicated profile seems like a reasonable workaround for now, e.g.:

        <profile>
            <id>dev</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <debug>false</debug>
            </properties>
            <build>
                <defaultGoal>quarkus:dev</defaultGoal>
            </build>
            <dependencies>
                <dependency>
                    <groupId>com.sun</groupId>
                    <artifactId>tools</artifactId>
                    <version>1.8</version>
                    <systemPath>${java.home}/../lib/tools.jar</systemPath>
                    <scope>system</scope>
                </dependency>
            </dependencies>
        </profile>

@springfan
Copy link

springfan commented Nov 17, 2020

@garyhodgson
That doesn't work for Java 11 as it in OpenJDK 11 tools.jar is not included anymore.

@famod
Copy link
Member

famod commented Mar 11, 2021

@jaikiran

Sorry, I have been a bit busy and wasn't able to look into this sooner. I will try and find some time this weekend and see what's going on and if I can help.

I know it's been over a year but did you ever manage to have a look at it?

@jaikiran
Copy link
Member

Hello @famod, in my last attempt I couldn't reproduce this. Even today I just gave this a try with 1.12.2.Final of Quarkus and used the steps below:

@jaikiran please see https://github.com/tobad357/quarkus-lombok-test
To trigger the issue do the following

    Start quarkus dev (./gradlew quarkusDev)
    Edit src/main/java/org/acme/ExampleResource.java and change the log message
    Reload the url http://0.0.0.0:8080/hello

This will give you the error if using the following JVM

OpenJDK 64-Bit GraalVM CE 19.2.1 (build 25.232-b07-jvmci-19.2-b03, mixed mode)

It works fine, no errors and the changes to the file are reflected. Of course, I used the latest Graal VM JDK 11 instead of 19.2.1

@famod
Copy link
Member

famod commented Mar 17, 2021

@jaikiran Thanks for checking!

In fact, a colleague of mine just tested Lombok with Quarkus 1.12.2 dev mode and constructor related changes seem to be working fine. Dev mode does a full reload for most changes though, but it works in general. We are using AdoptOpenJDK 11.0.10.

/cc @stuartwdouglas @geoand

@famod
Copy link
Member

famod commented Mar 17, 2021

So I think we can close this now. Please report back (or even better: create a new issue) if soemthing isn't working as expected with Lombok.

@famod famod closed this as completed Mar 17, 2021
@famod famod added the triage/out-of-date This issue/PR is no longer valid or relevant label Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant
Projects
None yet
Development

No branches or pull requests