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 #388

Open
Bing-ok opened this issue Mar 1, 2021 · 1 comment

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 java-gitlab-api. As shown in the following dependency tree, according to Maven's "nearest wins" strategy, only com.fasterxml.jackson.core:jackson-core:2.5.3 can be loaded, com.fasterxml.jackson.core:jackson-core:2.5.1_ and 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.5.3.

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

  1. com.fasterxml.jackson.core.JsonParser: com.fasterxml.jackson.core.JsonParser overrideStdFeatures(int,int) is invoked by java-gitlab-api via the following path:

Invocation path------
<org.gitlab.api.http.GitlabHTTPRequestor: java.lang.Object 'to'(java.lang.String,java.lang.Class,java.lang.Object)> java-gitlab-api\target\classes
<org.gitlab.api.http.GitlabHTTPRequestor: java.lang.Object parse(java.net.HttpURLConnection,java.lang.Class,java.lang.Object)> java-gitlab-api\target\classes
<com.fasterxml.jackson.databind.ObjectReader: java.lang.Object readValue(java.lang.String)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ObjectReader: java.lang.Object _bindAndClose(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.ObjectReader: com.fasterxml.jackson.core.JsonToken _initForReading(com.fasterxml.jackson.databind.DeserializationContext,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.DeserializationConfig: void initialize(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.core.JsonParser: com.fasterxml.jackson.core.JsonParser overrideStdFeatures(int,int)>
  1. com.fasterxml.jackson.core.JsonGenerator: com.fasterxml.jackson.core.JsonGenerator overrideFormatFeatures(int,int) is invoked by java-gitlab-api via the following path:

Invocation path------
<org.gitlab.api.http.GitlabHTTPRequestor: java.lang.Object 'to'(java.lang.String,java.lang.Class,java.lang.Object)> java-gitlab-api\target\classes
<org.gitlab.api.http.GitlabHTTPRequestor: void submitAttachments(java.net.HttpURLConnection)> java-gitlab-api\target\classes
<com.fasterxml.jackson.databind.ObjectMapper: java.lang.String writeValueAsString(java.lang.Object)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ObjectMapper: void _configAndWriteValue(com.fasterxml.jackson.core.JsonGenerator,java.lang.Object)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.SerializationConfig: void initialize(com.fasterxml.jackson.core.JsonGenerator)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.core.JsonGenerator: com.fasterxml.jackson.core.JsonGenerator overrideFormatFeatures(int,int)>
  1. com.fasterxml.jackson.core.JsonParser: com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int,int) is invoked by java-gitlab-api via the following path:

Invocation path------
<org.gitlab.api.http.GitlabHTTPRequestor: java.lang.Object 'to'(java.lang.String,java.lang.Class,java.lang.Object)> java-gitlab-api\target\classes
<org.gitlab.api.http.GitlabHTTPRequestor: java.lang.Object parse(java.net.HttpURLConnection,java.lang.Class,java.lang.Object)> java-gitlab-api\target\classes
<com.fasterxml.jackson.databind.ObjectReader: java.lang.Object readValue(java.lang.String)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ObjectReader: java.lang.Object _bindAndClose(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.ObjectReader: com.fasterxml.jackson.core.JsonToken _initForReading(com.fasterxml.jackson.databind.DeserializationContext,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.DeserializationConfig: void initialize(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.core.JsonParser: com.fasterxml.jackson.core.JsonParser overrideFormatFeatures(int,int)>
  1. com.fasterxml.jackson.core.JsonGenerator: void writeStartObject(java.lang.Object) is invoked by java-gitlab-api via the following path:

Invocation path------
<org.gitlab.api.http.GitlabHTTPRequestor: java.lang.Object 'to'(java.lang.String,java.lang.Class,java.lang.Object)> java-gitlab-api\target\classes
<org.gitlab.api.http.GitlabHTTPRequestor: void submitAttachments(java.net.HttpURLConnection)> java-gitlab-api\target\classes
<com.fasterxml.jackson.databind.ObjectMapper: java.lang.String writeValueAsString(java.lang.Object)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ObjectMapper: void _configAndWriteValue(com.fasterxml.jackson.core.JsonGenerator,java.lang.Object)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ser.DefaultSerializerProvider: void serializeValue(com.fasterxml.jackson.core.JsonGenerator,java.lang.Object)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ser.DefaultSerializerProvider: void _serialize(com.fasterxml.jackson.core.JsonGenerator,java.lang.Object,com.fasterxml.jackson.databind.JsonSerializer)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ser.BeanSerializer: void serialize(java.lang.Object,com.fasterxml.jackson.core.JsonGenerator,com.fasterxml.jackson.databind.SerializerProvider)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.core.JsonGenerator: void writeStartObject(java.lang.Object)>
  1. com.fasterxml.jackson.core.JsonGenerator: void writeFieldId(long) is invoked by java-gitlab-api via the following path:

Invocation path------
<org.gitlab.api.http.GitlabHTTPRequestor: java.lang.Object 'to'(java.lang.String,java.lang.Class,java.lang.Object)> java-gitlab-api\target\classes
<org.gitlab.api.http.GitlabHTTPRequestor: void submitAttachments(java.net.HttpURLConnection)> java-gitlab-api\target\classes
<com.fasterxml.jackson.databind.ObjectMapper: java.lang.String writeValueAsString(java.lang.Object)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ObjectMapper: void _configAndWriteValue(com.fasterxml.jackson.core.JsonGenerator,java.lang.Object)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ser.DefaultSerializerProvider: void serializeValue(com.fasterxml.jackson.core.JsonGenerator,java.lang.Object)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ser.DefaultSerializerProvider: void _serialize(com.fasterxml.jackson.core.JsonGenerator,java.lang.Object,com.fasterxml.jackson.databind.JsonSerializer)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ser.std.StdKeySerializers$Default: void serialize(java.lang.Object,com.fasterxml.jackson.core.JsonGenerator,com.fasterxml.jackson.databind.SerializerProvider)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.core.JsonGenerator: void writeFieldId(long)>
  1. <com.fasterxml.jackson.core.JsonGenerator: com.fasterxml.jackson.core.JsonGenerator overrideStdFeatures(int,int)> is invoked by java-gitlab-api via the following path:

Invocation path------
<org.gitlab.api.http.GitlabHTTPRequestor: java.lang.Object 'to'(java.lang.String,java.lang.Class,java.lang.Object)> java-gitlab-api\target\classes
<org.gitlab.api.http.GitlabHTTPRequestor: void submitAttachments(java.net.HttpURLConnection)> java-gitlab-api\target\classes
<com.fasterxml.jackson.databind.ObjectMapper: java.lang.String writeValueAsString(java.lang.Object)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.ObjectMapper: void _configAndWriteValue(com.fasterxml.jackson.core.JsonGenerator,java.lang.Object)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.databind.SerializationConfig: void initialize(com.fasterxml.jackson.core.JsonGenerator)> Repositories\com\fasterxml\jackson\core\jackson-databind\2.9.10.5\jackson-databind-2.9.10.5.jar
<com.fasterxml.jackson.core.JsonGenerator: com.fasterxml.jackson.core.JsonGenerator overrideStdFeatures(int,int)>

Suggested fixing solutions:

Upgrade direct dependency com.fasterxml.jackson.core:jackson-core from 2.5.3 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] org.gitlab:java-gitlab-api:jar:4.1.2-SNAPSHOT
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.5.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.10.5:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.10:compile
[INFO] |  \- (com.fasterxml.jackson.core:jackson-core:jar:2.9.10:compile - omitted for conflict with 2.5.3)
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.8.0-beta2:compile
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.2.0:test
[INFO] |  +- org.apiguardian:apiguardian-api:jar:1.0.0:test
[INFO] |  +- org.opentest4j:opentest4j:jar:1.1.0:test
[INFO] |  \- org.junit.platform:junit-platform-commons:jar:1.2.0:test
[INFO] |     \- (org.apiguardian:apiguardian-api:jar:1.0.0:test - omitted for duplicate)
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.2.0:test
[INFO] |  +- (org.apiguardian:apiguardian-api:jar:1.0.0:test - omitted for duplicate)
[INFO] |  +- org.junit.platform:junit-platform-engine:jar:1.2.0:test
[INFO] |  |  +- (org.apiguardian:apiguardian-api:jar:1.0.0:test - omitted for duplicate)
[INFO] |  |  +- (org.junit.platform:junit-platform-commons:jar:1.2.0:test - omitted for duplicate)
[INFO] |  |  \- (org.opentest4j:opentest4j:jar:1.1.0:test - omitted for duplicate)
[INFO] |  \- (org.junit.jupiter:junit-jupiter-api:jar:5.2.0:test - omitted for duplicate)
[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.junit.vintage:junit-vintage-engine:jar:5.2.0:test
[INFO] |  +- (org.apiguardian:apiguardian-api:jar:1.0.0:test - omitted for duplicate)
[INFO] |  +- (org.junit.platform:junit-platform-engine:jar:1.2.0:test - omitted for duplicate)
[INFO] |  \- (junit:junit:jar:4.12:test - omitted for duplicate)
[INFO] +- org.hamcrest:hamcrest-all:jar:1.3:test
[INFO] +- org.mockito:mockito-core:jar:2.10.0:test
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.7.4:test
[INFO] |  +- net.bytebuddy:byte-buddy-agent:jar:1.7.4:test
[INFO] |  \- org.objenesis:objenesis:jar:2.6:test
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.11.0:test
[INFO] +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.11.0:test
[INFO] |  +- (org.slf4j:slf4j-api:jar:1.8.0-alpha2:test - omitted for conflict with 1.8.0-beta2)
[INFO] |  +- (org.apache.logging.log4j:log4j-api:jar:2.11.0:test - omitted for duplicate)
[INFO] |  \- org.apache.logging.log4j:log4j-core:jar:2.11.0:test
[INFO] |     \- (org.apache.logging.log4j:log4j-api:jar:2.11.0:test - omitted for duplicate)
[INFO] \- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.5.1:compile
[INFO]    +- (com.fasterxml.jackson.core:jackson-core:jar:2.5.1:compile - omitted for conflict with 2.5.3)
[INFO]    \- (com.fasterxml.jackson.core:jackson-databind:jar:2.5.1:compile - omitted for conflict with 2.9.10.5)
@Bing-ok
Copy link
Author

Bing-ok commented Mar 7, 2021

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

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

No branches or pull requests

1 participant