Search code examples
javagradlejacksonmodule-info

module-info - module not found: com.fasterxml.jackson.core


I am trying to create a module-info file for my application but getting some issues with the com.fasterxml.jackson.core module when trying to build the application:

...\src\main\java\module-info.java:5: error: module not found: com.fasterxml.jackson.core
    requires com.fasterxml.jackson.core;

module-info:

module foo {
    requires org.slf4j;
    requires org.apache.commons.lang3;
    requires com.fasterxml.jackson.annotation;
    requires com.fasterxml.jackson.core;
    requires com.fasterxml.jackson.databind;
}

build.gradle:

...
dependencies {
    implementation 'org.slf4j:jcl-over-slf4j:2.0.7'

    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.1'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.15.1'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.1'

    implementation 'com.google.guava:guava:31.1-jre'

    // Logging
    implementation 'org.slf4j:slf4j-api:2.0.7'
    implementation 'org.apache.commons:commons-lang3:3.12.0'
    implementation 'commons-codec:commons-codec:1.15'

    // http tools
    api 'org.yamj:api-common:2.1'

    // testing
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.mockito:mockito-core:5.3.1'
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
}

java {
    withJavadocJar()
    withSourcesJar()
}
...

I'm using JDK 17 (Amazon Corretto) & Gradle 8.1.1

Does anyone know why this is happening and how to fix it? I've tried different versions of the jackson dependencies and still get the same issue.

If I remove

requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;

from the module-info.java, it will try to build but get errors about visibility:

...\src\main\java\foo\app.java:4: error: package com.fasterxml.jackson.databind is not visible
import com.fasterxml.jackson.databind.DeserializationFeature;
                            ^
  (package com.fasterxml.jackson.databind is declared in module com.fasterxml.jackson.databind, but module foo does not read it)

Solution

  • There was an Extra module-info.class in 2.15.1. This will be fixed in the next release: 2.15.2. Thanks to @VGR for pointing out that using version 2.15.0 will fix this issue, until the next version has been released.