简体   繁体   中英

Maven aws-java-sdk and aws-android-sdk conflict

In my maven project, I need to use aws-java-sdk-athena which has aws-java-sdk-core as a dependency. However for authentication, I have no other choices but using a provided artifact which has aws-android-sdk-core as a dependency. The problem is both of them have the com.amazonaws.http.ExecutionContext class with that exact same name. But they have different methods, etc..

I tried excluding one of them but then one of them goes off which mean those classes were used. I'm very frustrated now as it is nearly impossible to repackage one of these artifacts to change the package name in it.

<dependencies>
  <!-- This dependency requires aws-java-sdk-core 1.11.292 -->
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-athena</artifactId>
    <version>1.11.292</version>
  </dependency>

  <!-- This dependency requires aws-android-sdk-core 2.6.16 -->
  <dependency>
    <groupId>work.commons</groupId>
    <artifactId>work-commons-authentication</artifactId>
    <version>${authz.version}</version>
  </dependency>
<dependencies>
<repositories>
  <repository>
    <id>in.house</id>
    <name>nexus</name>
    <url>http://work.name.com/content/groups/public/</url>
    <snapshots>
      <enabled>true</enabled>
      <updatePolicy>always</updatePolicy>
    </snapshots>
  </repository>
</repositories>

At runtime, I got that exception:

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: com.amazonaws.http.ExecutionContext.setContextUserAgent(Ljava/lang/String;)

That because of both java-sdk and android-sdk have the exact class com.amazonaws.http.ExecutionContext but the class in java-sdk doesn't have setContextUserAgent method. If I change the order of dependencies, the Athena connection function broke.

Solved the problem by using a stand-alone JAR file of Athena JDBC driver. All the required classes are still there with different package name. So I didn't need to install the whole aws-java-sdk-core.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM