1

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)
Conor Egan
  • 518
  • 1
  • 3
  • 21
  • I downloaded jackson-core 2.15.1 from [here](https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core/2.15.1), and did `jar -d -f jackson-core-2.15.1.jar --release 17`. The output was rather bizarre; despite the filename, the .jar file contains a module with a completely different name, for all releases except 9. I don’t know if the Jackson team screwed up, or if this was some deliberate name change that is effective for more recent versions. – VGR May 18 '23 at 02:01
  • 1
    It looks like someone broke the .jar file, by adding multi-release branches with bad module-info for 11, 17, and 19. The 2.15.0 jackson-core .jar file is still correct, so one option you have is to downgrade to 2.15.0. – VGR May 19 '23 at 18:00
  • @VGR this worked, thank you! Is there a way I can report this bug to the jackson devs? – Conor Egan May 19 '23 at 19:46
  • 1
    I don’t know a lot about github, but… you may be able to report it at https://github.com/FasterXML/jackson/discussions, though you’ll probably need to create a github account if you don’t already have one. I don’t see a separate ‘Issues’ section for that project. – VGR May 19 '23 at 19:57
  • 1
    Did some searching and it has already been reported as an issue, and will be fixed in the 2.15.2 release. https://github.com/FasterXML/jackson-core/issues/1027 – Conor Egan May 19 '23 at 20:41
  • 1
    Feel free to answer your own question with your finding. – VGR May 19 '23 at 21:09

1 Answers1

1

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.

Conor Egan
  • 518
  • 1
  • 3
  • 21