jooq-codegen-maven plugin and JDK9 compilation error

Apparently the jooq-codegen-maven plugin uses the JAXB API, which is found in the Java EE module java.xml.bind. However, Java EE modules are not resolved by default (and also deprecated), which explains why the JVM complains that it can't find JAXBException.

To clarify: It's the JVM running the Maven process that is missing the dependency, not the compilation it launches!

The short term fix is to add the dependency manually with --add-modules to the JVM executing the plugin:

  • If the plugin allows forking (i.e. it can be executed in another JVM than the one running the Maven process), you might be able to add --add-modules java.xml.bind to it in your POM. A quick search suggest that that might not be possible.
  • Otherwise you need to configure the JVM running the Maven process, which you can do with the poorly documented .mvn/jvm.config file. Simply add such a file to the directory from which you launch the build (likely the one containing your POM) and put --add-modules java.xml.bind in there. (Unfortunate side effect: You can no longer build with Java 8.)

For a little more details on the second approach, check this newsletter that I wrote.


Version 3.10.0 - September 29, 2017

Just to mark this up to the date, you can now use JOOQ library version 3.10.0.

..is the first release that is formally integration tested with Java 9 along with the existing integration tests for Java 6/7 and for Java 8. To use jOOQ with Java 9 use the Java 8 distribution which has not yet been modularised, but contains Automatic-Module-Name specification to be forward compatible with future, modularised jOOQ distributions.

<plugin>
    <groupId>org.jooq</groupId>
    <artifactId>jooq-codegen-maven</artifactId>
    <version>3.10.0</version>
    ...
</plugin>

Tags:

Maven

Jooq

Java 9