Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“NoSuchMethodErrors” due to multiple versions of com.fasterxml.jackson.core:jackson-core #241

Closed
Bing-ok opened this issue Mar 1, 2021 · 5 comments

Comments

@Bing-ok
Copy link

Bing-ok commented Mar 1, 2021

Issue description:

There are multiple versions of com.fasterxml.jackson.core:jackson-core in jcabi-http. As shown in the following dependency tree, according to Maven's "nearest wins" strategy, only com.fasterxml.jackson.core:jackson-core:2.7.6 can be loaded, com.fasterxml.jackson.core:jackson-core:2.9.10 will be shadowed.

However, several methods defined in shadowed version com.fasterxml.jackson.core:jackson-core:2.9.10 are referenced by client project via com.fasterxml.jackson.core:jackson-databind:2.9.10.5 but missing in the actually loaded version com.fasterxml.jackson.core:jackson-core:2.7.6.

For instance, the following missing method(defined in com.fasterxml.jackson.core:jackson-core:2.9.10) are actually referenced by jcabi-http, which will introduce a runtime error(i.e., "NoSuchMethodError") into jcabi-http.

  1. com.fasterxml.jackson.core.JsonParser: boolean isNaN() is invoked by jcabi-http via the following path:

Invocation path------
<com.jcabi.http.response.JacksonResponse$JsonReader: com.fasterxml.jackson.databind.JsonNode read()> jcabi-http\target\classes
<com.fasterxml.jackson.databind.ObjectMapper: com.fasterxml.jackson.databind.JsonNode readTree(byte[])> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ObjectMapper: com.fasterxml.jackson.databind.JsonNode readTreeAndClose(com.fasterxml.jackson.core.JsonParser)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.deser.std.NumberDeserializers$NumberDeserializer: java.lang.Object deserialize(com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.DeserializationContext)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.core.JsonParser: boolean isNaN()>

Suggested fixing solutions:

Upgrade direct dependency com.fasterxml.jackson.core:jackson-core from 2.7.6 to 2.9.10. Because version 2.9.10 includes the above missing methods and is compatible with other versions of com.fasterxml.jackson.core:jackson-core in the project.

Thank you very much for your attention.
Best regards,

Dependency tree----


[INFO] com.jcabi:jcabi-http:jar:2.0-SNAPSHOT
[INFO] +- com.jcabi:jcabi-immutable:jar:1.4:compile
[INFO] |  \- (com.jcabi:jcabi-aspects:jar:0.22.6:compile - version managed from 0.20.1; omitted for duplicate)
[INFO] +- com.jcabi:jcabi-aspects:jar:0.22.6:compile
[INFO] |  +- (com.jcabi:jcabi-log:jar:0.19.0:compile - version managed from 0.17; omitted for duplicate)
[INFO] |  +- org.aspectj:aspectjrt:jar:1.8.13:compile (version managed from 1.8.7)
[INFO] |  \- (javax.validation:validation-api:jar:2.0.1.Final:compile - version managed from 1.1.0.Final; omitted for duplicate)
[INFO] +- com.jcabi:jcabi-log:jar:0.19.0:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.8.0-beta1:compile
[INFO] +- com.jcabi:jcabi-manifests:jar:1.1:compile
[INFO] |  \- (com.jcabi:jcabi-log:jar:0.19.0:compile - version managed from 0.14; omitted for duplicate)
[INFO] +- org.projectlombok:lombok:jar:1.18.12:provided
[INFO] +- javax.validation:validation-api:jar:2.0.1.Final:test (scope not updated to compile)
[INFO] +- org.apache.commons:commons-lang3:jar:3.8:test
[INFO] +- commons-io:commons-io:jar:2.7:provided
[INFO] +- javax.json:javax.json-api:jar:1.1.3:provided
[INFO] +- com.google.guava:guava:jar:21.0-rc2:provided
[INFO] +- (com.jcabi:jcabi-http:jar:1.16:provided - omitted for cycle)
[INFO] +- com.jcabi:jcabi-matchers:jar:1.5.1:provided
[INFO] |  +- (org.hamcrest:hamcrest:jar:2.2:provided - version managed from 2.1; omitted for duplicate)
[INFO] |  \- (com.jcabi:jcabi-log:jar:0.19.0:provided - version managed from 0.17.2; omitted for duplicate)
[INFO] +- org.hamcrest:hamcrest-core:jar:1.3:provided
[INFO] +- org.hamcrest:hamcrest-library:jar:1.3:provided
[INFO] |  \- (org.hamcrest:hamcrest-core:jar:1.3:provided - omitted for duplicate)
[INFO] +- com.jcabi:jcabi-xml:jar:0.22.2:provided
[INFO] |  +- (com.jcabi:jcabi-log:jar:0.19.0:provided - version managed from 0.18.1; omitted for duplicate)
[INFO] |  \- org.cactoos:cactoos:jar:0.20:provided
[INFO] +- org.junit.jupiter:junit-jupiter-params:jar:5.6.2:test
[INFO] |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] |  \- (org.junit.jupiter:junit-jupiter-api:jar:5.6.2:test - omitted for duplicate)
[INFO] +- javax.xml.bind:jaxb-api:jar:2.2.12:provided
[INFO] +- javax.xml.bind:jsr173_api:jar:1.0:provided
[INFO] +- javax.ws.rs:jsr311-api:jar:1.1.1:provided
[INFO] +- org.glassfish.grizzly:grizzly-http-servlet-server:jar:2.4.4:provided
[INFO] |  +- org.glassfish.grizzly:grizzly-http-server-core:jar:2.4.4:provided
[INFO] |  |  +- org.glassfish.grizzly:grizzly-core:jar:2.4.4:provided
[INFO] |  |  |  +- org.glassfish.grizzly:grizzly-framework:jar:2.4.4:provided
[INFO] |  |  |  \- org.glassfish.grizzly:grizzly-portunif:jar:2.4.4:provided
[INFO] |  |  |     \- (org.glassfish.grizzly:grizzly-framework:jar:2.4.4:provided - omitted for duplicate)
[INFO] |  |  +- org.glassfish.grizzly:grizzly-http-server:jar:2.4.4:provided
[INFO] |  |  |  \- org.glassfish.grizzly:grizzly-http:jar:2.4.4:provided
[INFO] |  |  |     \- (org.glassfish.grizzly:grizzly-framework:jar:2.4.4:provided - omitted for duplicate)
[INFO] |  |  +- org.glassfish.grizzly:grizzly-http-ajp:jar:2.4.4:provided
[INFO] |  |  |  \- (org.glassfish.grizzly:grizzly-http-server:jar:2.4.4:provided - omitted for duplicate)
[INFO] |  |  +- org.glassfish.grizzly:grizzly-http2:jar:2.4.4:provided
[INFO] |  |  |  \- (org.glassfish.grizzly:grizzly-http:jar:2.4.4:provided - omitted for duplicate)
[INFO] |  |  +- org.glassfish.grizzly:grizzly-npn-api:jar:1.9:provided
[INFO] |  |  \- org.glassfish.grizzly:grizzly-http-server-multipart:jar:2.4.4:provided
[INFO] |  |     +- (org.glassfish.grizzly:grizzly-framework:jar:2.4.4:provided - omitted for duplicate)
[INFO] |  |     \- (org.glassfish.grizzly:grizzly-http-server:jar:2.4.4:provided - omitted for duplicate)
[INFO] |  +- org.glassfish.grizzly:grizzly-http-servlet:jar:2.4.4:provided
[INFO] |  |  \- (org.glassfish.grizzly:grizzly-http-server:jar:2.4.4:provided - omitted for duplicate)
[INFO] |  \- org.glassfish.grizzly:grizzly-http-servlet-extras:jar:2.4.4:provided
[INFO] |     +- (org.glassfish.grizzly:grizzly-http-servlet:jar:2.4.4:provided - omitted for duplicate)
[INFO] |     +- (org.glassfish.grizzly:grizzly-http-server-multipart:jar:2.4.4:provided - omitted for duplicate)
[INFO] |     \- javax.servlet:javax.servlet-api:jar:4.0.1:provided (version managed from 4.0.0-b07)
[INFO] +- net.sourceforge.saxon:saxon:jar:9.1.0.8:provided
[INFO] +- net.sourceforge.saxon:saxon:jar:dom:9.1.0.8:provided
[INFO] +- org.glassfish.jersey.core:jersey-client:jar:2.25.1:provided
[INFO] |  +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:provided
[INFO] |  +- org.glassfish.jersey.core:jersey-common:jar:2.25.1:provided
[INFO] |  |  +- (javax.ws.rs:javax.ws.rs-api:jar:2.0.1:provided - omitted for duplicate)
[INFO] |  |  +- (javax.annotation:javax.annotation-api:jar:1.2:provided - omitted for duplicate)
[INFO] |  |  +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.25.1:provided
[INFO] |  |  +- (org.glassfish.hk2:hk2-api:jar:2.5.0-b32:provided - omitted for duplicate)
[INFO] |  |  +- (org.glassfish.hk2.external:javax.inject:jar:2.5.0-b32:provided - omitted for duplicate)
[INFO] |  |  +- (org.glassfish.hk2:hk2-locator:jar:2.5.0-b32:provided - omitted for duplicate)
[INFO] |  |  \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:provided
[INFO] |  +- org.glassfish.hk2:hk2-api:jar:2.5.0-b32:provided
[INFO] |  |  +- org.glassfish.hk2:hk2-utils:jar:2.5.0-b32:provided
[INFO] |  |  \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.5.0-b32:provided
[INFO] |  +- org.glassfish.hk2.external:javax.inject:jar:2.5.0-b32:provided
[INFO] |  \- org.glassfish.hk2:hk2-locator:jar:2.5.0-b32:provided
[INFO] |     +- (org.glassfish.hk2.external:javax.inject:jar:2.5.0-b32:provided - omitted for duplicate)
[INFO] |     +- (org.glassfish.hk2.external:aopalliance-repackaged:jar:2.5.0-b32:provided - omitted for duplicate)
[INFO] |     +- (org.glassfish.hk2:hk2-api:jar:2.5.0-b32:provided - omitted for duplicate)
[INFO] |     +- (org.glassfish.hk2:hk2-utils:jar:2.5.0-b32:provided - omitted for duplicate)
[INFO] |     \- org.javassist:javassist:jar:3.20.0-GA:provided
[INFO] +- org.apache.httpcomponents:httpcore:jar:4.4.14:provided
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.1:provided
[INFO] |  +- (org.apache.httpcomponents:httpcore:jar:4.4.3:provided - omitted for conflict with 4.4.14)
[INFO] |  +- commons-logging:commons-logging:jar:1.2:provided
[INFO] |  \- commons-codec:commons-codec:jar:1.12:provided (version managed from 1.9)
[INFO] +- org.glassfish:javax.json:jar:1.1.3:test
[INFO] |  \- (javax.json:javax.json-api:jar:1.1.3:provided - scope managed from test; omitted for duplicate)
[INFO] +- org.glassfish.jersey.core:jersey-server:jar:2.25.1:test
[INFO] |  +- (org.glassfish.jersey.core:jersey-common:jar:2.25.1:test - omitted for duplicate)
[INFO] |  +- (org.glassfish.jersey.core:jersey-client:jar:2.25.1:test - omitted for duplicate)
[INFO] |  +- (javax.ws.rs:javax.ws.rs-api:jar:2.0.1:test - omitted for duplicate)
[INFO] |  +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.25.1:test
[INFO] |  |  +- (org.glassfish.jersey.core:jersey-common:jar:2.25.1:test - omitted for duplicate)
[INFO] |  |  +- (org.glassfish.hk2:hk2-api:jar:2.5.0-b32:test - omitted for duplicate)
[INFO] |  |  +- (org.glassfish.hk2.external:javax.inject:jar:2.5.0-b32:test - omitted for duplicate)
[INFO] |  |  +- (org.glassfish.hk2:hk2-locator:jar:2.5.0-b32:test - omitted for duplicate)
[INFO] |  |  \- (org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:test - omitted for duplicate)
[INFO] |  +- javax.annotation:javax.annotation-api:jar:1.2:test
[INFO] |  +- (org.glassfish.hk2:hk2-api:jar:2.5.0-b32:test - omitted for duplicate)
[INFO] |  +- (org.glassfish.hk2.external:javax.inject:jar:2.5.0-b32:test - omitted for duplicate)
[INFO] |  +- (org.glassfish.hk2:hk2-locator:jar:2.5.0-b32:test - omitted for duplicate)
[INFO] |  \- (javax.validation:validation-api:jar:2.0.1.Final:test - version managed from 1.1.0.Final; omitted for duplicate)
[INFO] +- org.jsoup:jsoup:jar:1.13.1:provided
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.7.6:provided
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.10.5:provided
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.10:provided
[INFO] |  \- (com.fasterxml.jackson.core:jackson-core:jar:2.9.10:provided - omitted for conflict with 2.7.6)
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.6.2:test
[INFO] |  +- (org.apiguardian:apiguardian-api:jar:1.1.0:test - omitted for duplicate)
[INFO] |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  \- org.junit.platform:junit-platform-commons:jar:1.6.2:test
[INFO] |     \- (org.apiguardian:apiguardian-api:jar:1.1.0:test - omitted for duplicate)
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.6.2:test
[INFO] |  +- (org.apiguardian:apiguardian-api:jar:1.1.0:test - omitted for duplicate)
[INFO] |  +- org.junit.platform:junit-platform-engine:jar:1.6.2:test
[INFO] |  |  +- (org.apiguardian:apiguardian-api:jar:1.1.0:test - omitted for duplicate)
[INFO] |  |  +- (org.opentest4j:opentest4j:jar:1.2.0:test - omitted for duplicate)
[INFO] |  |  \- (org.junit.platform:junit-platform-commons:jar:1.6.2:test - omitted for duplicate)
[INFO] |  \- (org.junit.jupiter:junit-jupiter-api:jar:5.6.2:test - omitted for duplicate)
[INFO] +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] +- org.mockito:mockito-core:jar:3.5.0:test
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.10.13:test
[INFO] |  +- net.bytebuddy:byte-buddy-agent:jar:1.10.13:test
[INFO] |  \- org.objenesis:objenesis:jar:3.1:test
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.8.0-beta1:test
[INFO] |  +- (org.slf4j:slf4j-api:jar:1.8.0-beta1:test - omitted for duplicate)
[INFO] |  \- (log4j:log4j:jar:1.2.17:test - omitted for duplicate)
[INFO] \- log4j:log4j:jar:1.2.17:test
@0crat 0crat added the 0crat/new label Mar 1, 2021
@Bing-ok
Copy link
Author

Bing-ok commented Mar 7, 2021

@andreoss Could you please help me review this issue? Thank you very much.

@andreoss
Copy link
Collaborator

andreoss commented Mar 8, 2021

@Bing-ok
Do you have any json which causes this?
I failed to reproduce NoSuchMethodError.
JacksonParser as it configured does not support NaN whatsoever, but if enabled this test passes

    @Test
    void canReadNan() throws IOException {
        final JacksonResponse response = new FakeRequest()
            .withBody("{\"x\": NaN}")
            .fetch().as(JacksonResponse.class);
        final ObjectNode object = response.json().readObject();
        MatcherAssert.assertThat(
            object.get("x").asDouble(), Matchers.is(Double.NaN)
        );
    }

andreoss added a commit to andreoss/jcabi-http that referenced this issue Mar 8, 2021
andreoss added a commit to andreoss/jcabi-http that referenced this issue Mar 8, 2021
@Bing-ok
Copy link
Author

Bing-ok commented Mar 9, 2021

Thanks for your support! Using the latest version can also fix this issue. @andreoss

@Bing-ok Bing-ok closed this as completed Mar 9, 2021
@0crat
Copy link

0crat commented Mar 9, 2021

Job gh:jcabi/jcabi-http#241 is not assigned, can't get performer

@andreoss
Copy link
Collaborator

@Bing-ok Fixed in 1.17.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants