timols / java-gitlab-api

A wrapper for the Gitlab API written in Java
Apache License 2.0
387 stars 317 forks source link

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

Open Bing-ok opened 3 years ago

Bing-ok commented 3 years ago

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)>
    
  2. 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)>
    
  3. 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)>
    
  4. 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)>
    
  5. 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)>
    
  6. <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 commented 3 years ago

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