玩之间的冲突!框架2.5和gRPC 0.13 [英] Conflict between Play! Framework 2.5 and gRPC 0.13

查看:105
本文介绍了玩之间的冲突!框架2.5和gRPC 0.13的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Play 2.5.0使用Netty 4.0.33,而gRPC需要Netty 4.1.0(用于http2支持),这会导致以下异常:

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

[error] p.c.s.n.PlayRequestHandler - 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] p.c.s.n.PlayRequestHandler - 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)

删除所有gRPC代码后,它又可以正常工作.

After I remove all gRPC codes, it works again.

我现在可以尝试快速修复吗?谢谢!

Is there any quick fix that I can try now? Thanks!

推荐答案

播放2.6.0已发布,它正在使用Netty 4.1.

Play 2.6.0 was released and it is using Netty 4.1.

由于Netty 4和Netty 4.1之间的二进制不兼容,因此Play 2.5.0和gRPC不兼容.

Play 2.5.0 and gRPC are not compatible due to binary incompatibilities between Netty 4 and Netty 4.1.

这就是为什么它不能在Play 2.5.0上运行而在Play 2.4.0上运行的原因:

Here is why it don't work with Play 2.5.0 but works with Play 2.4.0:

Play 2.5.0使用Netty版本4.0.33.Final,该版本声明(通过

Play 2.5.0 uses Netty version 4.0.33.Final, which is declared (transitively via netty-reactive-streams version 1.0.2) like this:

<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>

版本4.0.33.Final由版本4.0.34.Final逐出,该版本由 async-http暂时添加-client ,这是Play 2.5.0使用的netty依赖项:

Version 4.0.33.Final is evicted by version 4.0.34.Final which was added transitively by async-http-client and these are the netty 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

在另一端播放2.4.6,仅需要以下netty依赖项:

Play 2.4.6 on the other side, requires just the following netty dependency:

io.netty:netty:3.8.0.Final

因此,尽管Play 2.5.0依赖于许多较小的Netty软件包,但是Play 2.4.6仅依赖于一个Netty软件包.那是因为Netty 4 更改了项目结构将项目拆分为多个子项目,以便用户可以仅从Netty添加必需的功能.甚至更重要的是," Netty的软件包名称已从org.jboss.netty更改为io.netty ".

So, while Play 2.5.0 depends on a lot of smaller netty packages, Play 2.4.6 depends just on a single netty package. That is because Netty 4 changed the project structure to split the project into multiple subprojects so that a user can add just the necessary features from Netty. And even more important "the package name of Netty has been changed from org.jboss.netty to io.netty".

为什么这些更改在这里都很重要:

Why are these changes both important here:

  1. gRPC与2.4.6之间没有依赖项冲突,因为gRPC不需要依赖项io.netty:netty,甚至不需要传递性.因此,没有迁离的机会.
  2. 在类级别没有冲突,因为类具有不同的程序包名称(org.jboss.nettyio.netty),然后具有不同的全限定名.它们被视为不同的类.
  1. There is no dependency conflict between gRPC with 2.4.6 because gRPC does not requires dependency io.netty:netty, not even transitively. Because of that, there is no eviction.
  2. There is no conflict at class level because the classes had different packages names (org.jboss.netty and io.netty) and then have different full qualified names. They are being treated as different classes.

与Play 2.5.0发生冲突是因为Netty 4和Netty 4.1都具有相同的依赖项(然后4.0.34被4.1驱逐了),并且由于-由于我们现在具有 same (完全相同)这两个版本之间的类名-二进制文件不兼容.

There are conflicts with Play 2.5.0 because Netty 4 and Netty 4.1 have both the same dependencies (then 4.0.34 being evicted by 4.1) and because - since we now have the same full qualified class names between these two versions - binaries incompatibilities arise.

这是一个很长的解释,说没有办法使gRPC和Play 2.5.0现在与Netty一起工作.即使您决定使用 Akka HTTP服务器后端,也有可能与Play WS发生冲突.

That is a long explanation to say that there is no way to make gRPC and Play 2.5.0 work together right now with Netty. Even if you decide to use Akka HTTP server backend, there is a chance of conflict with Play WS.

这篇关于玩之间的冲突!框架2.5和gRPC 0.13的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆