Lombok: Error: java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi

Created on 7 Aug 2018  路  7Comments  路  Source: projectlombok/lombok

In my Java 11 Module project I have added the Maven dependency:

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

In my module-info I added

requires static lombok

but when I run my application in Eclipse Photon I get the error:

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

Did I forget to declare something?

Most helpful comment

'transitive' seems like that'd be wrong. I've added requires static org.mapstruct.processor; instead. Not sure this will work, the entire concept is basically FUBAR here and it seems impossible to have a lombok which CAN interact with mapstruct if you have that in your compilation run but doesn't require it to be there.

We weren't quite ready to mess with j11 just yet; we'd love some feedback if the hack we just cooked up actually would work.

Mind giving the edge-release a spin, @tzieleniewski / @arrowman53 ?

https://projectlombok.org/download-edge

All 7 comments

There is a module jar that exposes the package: mapstruct-processor-1.3.0.Beta1.jar
The module-info.java of lombok has to be extended with 'requires transitive org.mapstruct.processor;' to solve this issue.

I got the same error when trying to investigate project dependencies with jdeps in the module-path mode.

'transitive' seems like that'd be wrong. I've added requires static org.mapstruct.processor; instead. Not sure this will work, the entire concept is basically FUBAR here and it seems impossible to have a lombok which CAN interact with mapstruct if you have that in your compilation run but doesn't require it to be there.

We weren't quite ready to mess with j11 just yet; we'd love some feedback if the hack we just cooked up actually would work.

Mind giving the edge-release a spin, @tzieleniewski / @arrowman53 ?

https://projectlombok.org/download-edge

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.

I will test it and return with feedback.

I did some tests and got the following:

  • when project is packaged as modular JAR it works with lombok version 1.18.2.
  • when project is packaged as non-modular JAR it doesn't work with version 1.18.2 but works with edge.

You can try here - two example branches for this issue (lombok-issue-1806-..).
https://github.com/tzieleniewski/lombok-examples

Environment
Apache Maven 3.5.3
Java version: 10.0.1, vendor: Oracle Corporation
Default locale: pl_PL, platform encoding: Cp1250
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Modular JAR

C:\Users\tomasz.zieleniewski\Desktop\tmp\lombok-examples>jdeps --module-path target/dependency -R target/lombok-examples-1.0.0-SNAPSHOT.jar
com.intive
 [file:///C:/Users/tomasz.zieleniewski/Desktop/tmp/lombok-examples/target/lombok-examples-1.0.0-SNAPSHOT.jar]
   requires mandated java.base (@10.0.1)
   requires static lombok
com.intive -> java.base
   com.intive                                         -> java.lang                                          java.base

Non-modular JAR with 1.18.2

C:\Users\tomasz.zieleniewski\Desktop\tmp\lombok-examples>jdeps --module-path target/dependency -R target/lombok-examples-1.0.0-SNAPSHOT.jar
Error: Module lombok does not read a module that exports org.mapstruct.ap.spi

Non-modular JAR with edge

C:\Users\tomasz.zieleniewski\Desktop\tmp\lombok-examples>jdeps --module-path target/dependency -R target/lombok-examples-1.0.0-SNAPSHOT.jar
lombok-examples-1.0.0-SNAPSHOT.jar -> java.base
   com.intive                                         -> java.lang                                          java.base
   com.intive                                         -> java.lang.invoke                                   java.base
lombok
 [file:///C:/Users/tomasz.zieleniewski/Desktop/tmp/lombok-examples/target/dependency/lombok-edge.jar]
   requires mandated java.base (@9.0.1)
   requires java.compiler (@9.0.1)
   requires java.instrument (@9.0.1)
   requires jdk.unsupported (@9.0.1)
   requires static org.mapstruct.processor
lombok -> java.base
lombok -> java.compiler
lombok -> java.instrument
lombok -> jdk.compiler
lombok -> jdk.unsupported
lombok -> not found
lombok -> org.mapstruct.processor
   lombok                                             -> java.lang                                          java.base
...

I also faced such issue then I realized like
a) I have added the Lombok jar manually that is the main cause once I add the entries of Lombok in pom.xml it worked
and I have removed that jar dependency jar which I added Earlier.

Was this page helpful?
0 / 5 - 0 ratings