Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-777

"NoSuchMethodErrors" due to multiple versions of commons-codec:commons-codec:jar

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.7.0
    • None

    Description

      Issue description

      Hi, there are multiple versions of commons-codec:commons-codec in commons-vfs(commons-vfs2 module). As shown in the following dependency tree, according to Maven's "nearest wins" strategy, only commons-codec:commons-codec:1.2 can be loaded, commons-codec:commons-codec:1.11 and commons-codec:commons-codec:1.13 will be shadowed.

      However, one method defined in shadowed version commons-codec:commons-codec:1.11 is referenced by client project via org.apache.httpcomponents:httpclient:4.5.12, but missing in the actually loaded version commons-codec:commons-codec:1.2.

      For instance, the following missing method(defined in commons-codec:commons-codec:1.11) is actually referenced by commons-vfs(commons-vfs2 module), which will introduce a runtime error(i.e., "NoSuchMethodError") into commons-vfs(commons-vfs2 module).

      Missing method: org.apache.commons.codec.binary.Base64: void init (int) is invoked by commons-vfs(commons-vfs2 module) via the following path:

      paths------
      <org.apache.commons.vfs2.provider.http4.Http4FileObject: org.apache.http.HttpResponse executeHttpUriRequest(org.apache.http.client.methods.HttpUriRequest)> commons-vfs-master\commons-vfs2\target\classes
      <org.apache.http.impl.client.DecompressingHttpClient: org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest,org.apache.http.protocol.HttpContext)> Repositories\org\apache\httpcomponents\httpclient\4.5.12\httpclient-4.5.12.jar
      <org.apache.http.impl.client.DecompressingHttpClient: org.apache.http.HttpResponse execute(org.apache.http.HttpHost,org.apache.http.HttpRequest,org.apache.http.protocol.HttpContext)> Repositories\org\apache\httpcomponents\httpclient\4.5.12\httpclient-4.5.12.jar
      <org.apache.http.client.protocol.RequestTargetAuthentication: void process(org.apache.http.HttpRequest,org.apache.http.protocol.HttpContext)> Repositories\org\apache\httpcomponents\httpclient\4.5.12\httpclient-4.5.12.jar
      <org.apache.http.client.protocol.RequestAuthenticationBase: void process(org.apache.http.auth.AuthState,org.apache.http.HttpRequest,org.apache.http.protocol.HttpContext)> Repositories\org\apache\httpcomponents\httpclient\4.5.12\httpclient-4.5.12.jar
      <org.apache.http.client.protocol.RequestAuthenticationBase: org.apache.http.Header authenticate(org.apache.http.auth.AuthScheme,org.apache.http.auth.Credentials,org.apache.http.HttpRequest,org.apache.http.protocol.HttpContext)> Repositories\org\apache\httpcomponents\httpclient\4.5.12\httpclient-4.5.12.jar
      <org.apache.http.impl.auth.BasicScheme: org.apache.http.Header authenticate(org.apache.http.auth.Credentials,org.apache.http.HttpRequest,org.apache.http.protocol.HttpContext)> Repositories\org\apache\httpcomponents\httpclient\4.5.12\httpclient-4.5.12.jar
      <org.apache.commons.codec.binary.Base64: void <init>(int)>

      Suggested fixing solutions

      1.Use configuration attribute <dependencyManagement> to unify the version of library commons-codec:commons-codec to be 1.11 in commons-vfs(commons-vfs2 module)'s pom file.
      2. Declare a direct dependency commons-codec:commons-codec1.11 to upgrade version from 1.2 to 1.11.
      3.use <exclude> to exclude commons-codec:commons-codec:1.2 from the dependency tree, so that version 1.11 will be loaded.

      Please let me know which solution do you prefer? I can submit a PR to fix it.

      Thank you very much for your attention.
      Best regards,

      Dependency tree----

      [INFO] org.apache.commons:commons-vfs2:jar:2.7.0-SNAPSHOT
       [INFO] +- commons-httpclient:commons-httpclient:jar:3.1:compile
       [INFO] | - *commons-codec:commons-codec:jar:1.2:compile*
       [INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.12:compile
       [INFO] | - *(commons-codec:commons-codec:jar:1.11:compile - omitted for conflict with 1.2)*
       [INFO] +- org.apache.httpcomponents.client5:httpclient5:jar:5.0:compile
       [INFO] | - *(commons-codec:commons-codec:jar:1.13:compile - omitted for conflict with 1.2)*
       [INFO] +- org.apache.hadoop:hadoop-common:test-jar:tests:3.2.1:test
       [INFO] | +- (commons-codec:commons-codec:jar:1.11:test - omitted for conflict with 1.2)
       [INFO] | - org.apache.hadoop:hadoop-auth:jar:3.2.1:test
       [INFO] | - (commons-codec:commons-codec:jar:1.11:test - omitted for conflict with 1.2)
       [INFO] - org.apache.hadoop:hadoop-hdfs:test-jar:tests:3.2.1:test
       [INFO] - (commons-codec:commons-codec:jar:1.11:test - omitted for conflict with 1.2)

      Attachments

        Activity

          People

            Unassigned Unassigned
            Bing-ok Bing-ok
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: