Ad

Maven Aws-java-sdk And Aws-android-sdk Conflict

- 1 answer

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.

Ad

Answer

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.

Ad
source: stackoverflow.com
Ad