Conflict between Play! Framework 2.5 and gRPC 0.13

Play 2.5.0 uses Netty 4.0.33, while gRPC requires Netty 4.1.0 (to support http2), which raises the following exception:

[error] pcsnPlayRequestHandler - Exception caught in Netty java.lang.AbstractMethodError: null at io.netty.util.ReferenceCountUtil.touch(ReferenceCountUtil.java:73) at io.netty.channel.DefaultChannelPipeline.touch(DefaultChannelPipeline.java:84) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:154) at com.typesafe.netty.http.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:131) at com.typesafe.netty.http.HttpStreamsServerHandler.channelRead(HttpStreamsServerHandler.java:96) at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83) at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:154) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:154) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83) [error] pcsnPlayRequestHandler - Exception caught in Netty java.util.NoSuchElementException: http-handler-body-publisher at io.netty.channel.DefaultChannelPipeline.getContextOrDie(DefaultChannelPipeline.java:1050) at io.netty.channel.DefaultChannelPipeline.remove(DefaultChannelPipeline.java:379) at com.typesafe.netty.http.HttpStreamsHandler.handleReadHttpContent(HttpStreamsHandler.java:191) at com.typesafe.netty.http.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:167) at com.typesafe.netty.http.HttpStreamsServerHandler.channelRead(HttpStreamsServerHandler.java:96) at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83) at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:154) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:154) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83) 

After deleting all the gRPC codes, it works again.

Is there a quick fix I can try now? Thanks!

+6
source share
3 answers

Edit:

"Play 2.6.0" was released and it uses Netty 4.1.

TL; DR

Play 2.5.0 and gRPC are incompatible due to binary incompatibility between Netty 4 and Netty 4.1.


This is why it does not work with Play 2.5.0, but it works with Play 2.4.0:

Play 2.5.0 uses version Netty 4.0.33.Final , which is declared (transitively through netty-reactive streams version 1.0.2 ) for example:

 <dependency> <groupId>io.netty</groupId> <artifactId>netty-handler</artifactId> <version>4.0.33.Final</version> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-codec-http</artifactId> <version>4.0.33.Final</version> </dependency> 

Version 4.0.33.Final superseded by version 4.0.34.Final , which was added transitively via async-http-client , and these are the network dependencies used by Play 2.5.0:

 io.netty:netty-buffer:4.0.34.Final io.netty:netty-codec-http:4.0.34.Final io.netty:netty-codec:4.0.34.Final io.netty:netty-common:4.0.34.Final io.netty:netty-handler:4.0.34.Final io.netty:netty-transport:4.0.34.Final 

Listening to 2.4.6 on the other hand requires only the following netty dependency:

 io.netty:netty:3.8.0.Final 

So, while Play 2.5.0 depends on many small net packages, Play 2.4.6 depends on only one netty package. This is due to the fact that Netty 4 changed the structure of the project to divide the project into several subprojects so that the user can add only the necessary functions from Netty. More importantly, "the Netty package name has been changed from org.jboss.netty to io.netty ."

Why are these changes important here:

  • There is no dependency conflict between gRPC with 2.4.6, because gRPC does not require the io.netty:netty dependency, not even transitively. Because of this, there is no eviction.
  • There are no conflicts at the class level because the classes had different package names ( org.jboss.netty and io.netty ), and then they have different full names. They are considered as different classes.

There are conflicts with Play 2.5.0, because Netty 4 and Netty 4.1 have the same dependencies (then 4.0.34 are superseded by 4.1), and because now we have the same full class names between these two versions - binary incompatibilities arise files.

This is a long explanation to say that now there is no way to get gRPC and Play 2.5.0 to work with Netty. Even if you decide to use the server server server Akka , there is a possibility of a conflict with Play WS.

+11
source

I also came across this on Play using Java. Do you use the gRPC client or server interface with the playback server? If you just use only the client, you can overcome this by using the OKHTTP client version instead of the one that relies on Netty.

https://mvnrepository.com/artifact/io.grpc/grpc-okhttp

If you use a server, I think you might be out of luck. You can try to exclude Netty from gRPC and hope that the Play version is enough. Just add excludeAll ExclusionRule (organization = "io.netty") to your gRPC import.

Here is the thread on the game’s mailing list on this topic, but so far they have no changes to this topic: https://groups.google.com/forum/#!topic/play-framework/TWa18IfZ5kA

0
source

You can also use the maven-shade plugin to move Netty package names so you don't run into an earlier version.

Take a look at the couvbase jvm core library for an example https://github.com/couchbase/couchbase-jvm-core .

0
source

All Articles