Lombok: [BUG] Lombok module not working

Created on 11 May 2019  路  17Comments  路  Source: projectlombok/lombok

The problem
Compiling even an hello world app results in the following problem:

Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi

To Reproduce
The error occurs even in a fresh hello world eclipse project. With or without a specific module-info.java.

Version info:

  • Lombok version: 1.18.6
  • Eclipse version: 2019-03 (4.11.0)
  • Java version: AdoptOpenJDK 11.0.3 (2019-04-16) with Hotspot VM
  • I'm not currently using any custom build tool like maven, gradle or ant.
parked

Most helpful comment

In issue https://github.com/rzwitserloot/lombok/issues/1806 suggests people were able to fix it, but this comment is a bit vague:
Arrowman53: "I have tested the lombok-edge version with your patch with JavaSE-10 and it worked fine now but only after I also added the mapstruct-processor-1.3.0.Beta1.jar to my module path."

It works for me when I add the following to the pom:

<dependency>
    <groupId>org.mapstruct</groupId>
    <artifactId>mapstruct-processor</artifactId>
    <version>1.3.0.Final</version>
</dependency>

All 17 comments

Can you try lombok 1.18.8 (the current most recent version)? I think we fixed this.

I tried it with lombok 1.18.8. Still the same message.
In case it was a problem with my JDK, I tested it with a SapMachine JDK 11; that didn't work either.

Can I help you somehow else to reproduce?

I moved the lombok dependency from the Modulepath to the Classpath. That fixed the problem on my machine.

At this time, I do not know if that's a good and valid solution.

Can anyone tell me why it isn't?

It is a possible workaround, but since all classpath dependencies will be put in the unnamed module, ALL classes that need access to lombok must also be in the unnamed module (i.e. classpath).

So this workaround will only work when you're able to downgrade everything to classpath. (Which I was able to for now)

Thanks for your help!

In issue https://github.com/rzwitserloot/lombok/issues/1806 suggests people were able to fix it, but this comment is a bit vague:
Arrowman53: "I have tested the lombok-edge version with your patch with JavaSE-10 and it worked fine now but only after I also added the mapstruct-processor-1.3.0.Beta1.jar to my module path."

It works for me when I add the following to the pom:

<dependency>
    <groupId>org.mapstruct</groupId>
    <artifactId>mapstruct-processor</artifactId>
    <version>1.3.0.Final</version>
</dependency>

I haven't tried it with an up-to-date mapstruct-processor yet but it seems to help.
I'll try it out when I have more time.
Maybe including it in lombok would be a general fix for the issue?

I wrote how to fix it as part of my blog post:
https://medium.com/@Leejjon_net/youll-have-this-problems-when-you-add-lombok-to-a-modular-java-11-micro-service-832f55911bc5

But yes, if lombok depends on it it should just be a sub dependency for lombok.

I have tried the workaround (updating to mapstruct-processor 1.3.0.Final) and it did not work. Currently compiling with JDK 13 (as 11 doesn't work for me due to another bug).

Code is at https://github.com/GoMint/GoMint (module gomint-server), compiled with a IntelliJ IDEA run configuration (debug)

Lombok Version: 1.18.8
JDK 13 build 30, Windows x64
IDE: IntelliJ 192.5728.74

We're considering splitting of the mapstruct integration code to a separate module that has both lombok and mapstruct as a dependency.

That should solve these issues.

No promises on the delivery date though. Pull requests are welcome. Fair warning: Our build script is complicated. For a reason. We will not accept pull request that try to improve it by moving it to gradle/maven/etc.

Hi
I am getting same issue : module not found: lombok
with version Lombok 1.18.8 .
IDE: IntelliJ IDEA 2019.1.3

In issue #1806 suggests people were able to fix it, but this comment is a bit vague:
Arrowman53: "I have tested the lombok-edge version with your patch with JavaSE-10 and it worked fine now but only after I also added the mapstruct-processor-1.3.0.Beta1.jar to my module path."

It works for me when I add the following to the pom:

<dependency>
    <groupId>org.mapstruct</groupId>
    <artifactId>mapstruct-processor</artifactId>
    <version>1.3.0.Final</version>
</dependency>

Same here seems to fix it in combination with edge version. Pretty ugly tho 馃槵

So just that you guys have some feedback on the current state of affairs in the field:
Everything was OK until I started to modularize my project (Eclipse 4.14/2019-12 + maven 3.6.3 + JDK 13) some hours ago using only

<dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.10</version>
            <scope>provided</scope>
</dependency>

Starting modularization, (with the inevitable requires static lombok) in the module-info, i had the following issues:

  • delombock failed (unfixable as of now, see below)
  • the lombok proessor wasn't picked up by the compiler.
    This could be fixed by by adding lombok to the annotation path like so:
<plugin>
         <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
                    <annotationProcessorPaths>
                        <dependency>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </dependency>
                    </annotationProcessorPaths>
            </configuration>
 </plugin>

Still, surefire then failed rather ugly, as Leejoon pointed out in his blogpost, with something like
Error occurred during initialization of boot layer java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi
(I say ugly, because you won't see this cause if your surefire version is 2.20 or later, because it is hidden in an arcane .dump, instead of beeing shown on the console).
Again, as indicated, this can be fixed, with
<dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <scope>test</scope> <version>1.3.*** your prefered version</version> </dependency>
Scope 'test' seems to be sufficient, none of the downstream projects (all of them OSGi, *not
java modules) complain about missing mapstruct so far, but this might change.

All of this persisted, when I switched to 1.18.12. None of this had impact on my Eclipse IDE. So the only casualty seems to be delombok, which spams the log with messages
module not found: xxxx requires xxxx;
for every annotated *.java, and failing to delombok them.
Btw, maven central doesn't have a matching 1.18.12 lombok-maven-plugin so far.

In the latest edge release we've split off the mapstruct binding. Can someone verify that that fixes this problem?

In my modular Java 11 test project, I can safely remove the mapstruct-processor dependency and switch to the edge release and it still builds and runs correctly:
https://github.com/Leejjon/SimpleJerseyService/commit/3aa8abb24042db704e78ec074867662ee530e62f

Edge version: 1.18.13 (2020-03-15 06:01:00 UTC working correctly!

Current edge version fixes the issue
(OpenJDK11U-jdk_x64_linux_hotspot_11.0.6_10 + eclipse-java-2020-03-R-linux-gtk-x86_64)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lombokissues picture lombokissues  路  34Comments

ilgrosso picture ilgrosso  路  76Comments

lombokissues picture lombokissues  路  42Comments

lex-em picture lex-em  路  61Comments

arana198 picture arana198  路  53Comments