commercetools / commercetools-jvm-sdk

The e-commerce SDK from commercetools running on the Java virtual machine.
https://commercetools.github.io/commercetools-jvm-sdk/apidocs/index.html
Other
62 stars 40 forks source link

Async HTTP client and Spring Boot 2 version clash #1751

Closed garfailed closed 6 years ago

garfailed commented 6 years ago

Hi,

When we upgraded to Spring Boot 2, we ran into this error:

WARN  io.netty.util.concurre.DefaultPromise - An exception was thrown by org.asynchttpclient.netty.request.NettyRequestSender$1.operationComplete()
java.lang.NoSuchMethodError: io.netty.channel.DefaultChannelId.newInstance()Lio/netty/channel/DefaultChannelId;

As it turns out both Spring Boot, and the async-http-client (at least the version present in the Commercetools SDK) use the netty.version property.

This causes the Spring Boot property to override the async-http-client's Netty version, and since the version in Commercetools is a bit out of date it fails with the error linked above.

The workaround was to explicitly specify the older netty.version in our own pom.xml, and since nothing else uses Netty, this doesn't cause any issues (for us at least).

acbeni commented 6 years ago

@garfailed The problem is related to some breaking change in netty2, In order to be able to work with Spring Boot 2 , just make sure you remove the following dependencies:

<dependency>
    <groupId>com.commercetools.sdk.jvm.core</groupId>
    <artifactId>commercetools-java-client-ahc-2_0</artifactId> . 
    <version>${used.version}</version>
</dependency>
<dependency>
    <groupId>com.commercetools.sdk.jvm.core</groupId>
    <artifactId>sdk-http-ahc-2_0</artifactId>
    <version>${used.version}</version>
</dependency>

and replace it with

<dependency>
    <groupId>com.commercetools.sdk.jvm.core</groupId>
    <artifactId>sdk-http-apache-async</artifactId>
    <version>${used.version}</version>
</dependency>
<dependency>
    <groupId>com.commercetools.sdk.jvm.core</groupId>
    <artifactId>commercetools-java-client-apache-async</artifactId>
    <version>${used.version}</version>
</dependency>

and that's it, this client has no dependency on netty so there will be no conflict.

acbeni commented 6 years ago

if that works for you let me know so i close the issue @garfailed

garfailed commented 6 years ago

Thank you, that was the solution we originally used, and what was suggested by your support, but it was bugging me that I didn't know why the async-http-client failed. I just opened this issue to let people know that there is a workaround if they prefer the async-http-client library.

Do you have any plans to upgrade to the async-http-client to a more recent version (2.4.5 currently)?

acbeni commented 6 years ago

Updating async-http-client should't be a big deal, i will add it to the next release.