JOOQ with Gradle and Java 11

Marek Scholle
2 min readOct 31, 2018

Update 2021–01–29. This is still found by some people. Things have moved in the meantime, we have Java 15, new versions of JOOQ do not have described problems and using buildscriptinside Gradle script is deprecated. You have been warned.

This will be short and pragmatic as I only needed to make things work again and I am not willing to dig deeper. In our company, we use

  • JOOQ to access our SQL databases
  • Gradle for our Java and Scala (mostly mixed) builds
  • gradle-jooq-plugin
  • most recent platforms and libraries available

When Java 9 introduced modularization efforts, our JOOQ codegen phase was suddenly broken due to missing JAXB dependency. The simplest solution was to add

org.gradle.jvmargs=--add-modules java.xml.bind

to our gradle.properties.

In Java 11, —-add-modules is no more allowed. Without it, we get

Execution failed for task ':generate***'.
> javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]

Should we stay with JDK 10 until full JOOQ support for Java 11 — of course not! I failed to google any working solution (?), only found this note

JAXB has been removed from the JDK in JDK 11. It causes jOOQ users some extra trouble to configure when setting up jOOQ for the first time

So I had to dive into Gradle and after a while, I got it

// file: build.gradlebuildscript {
dependencies {
classpath 'org.glassfish.jaxb:jaxb-runtime:2.3.1'
}
}
plugins {
...
id 'nu.studer.jooq' version '3.0.2'
...
}
dependencies {
...

jooqRuntime group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.1'

jooqRuntime group: 'com.sun.activation', name: 'javax.activation', version: '1.2.0'
...
}

Hope this helps.

--

--