本文介绍了将Google云端客户端库添加到Play 2.5时获取ChannelException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是一些堆栈跟踪

  io.netty.channel.ChannelException:无法从类class io创建通道.netty.channel.socket.nio.NioServerSocketChannel 
at io.netty.channel.ReflectiveChannelFactory.newChannel(ReflectiveChannelFactory.java:41)
at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java: 318)
在io.netty.bootstrap.AbstractBootstrap.doBind(AbstractBootstrap.java:282)
在io.netty.bootstrap.AbstractBootstrap.bind(AbstractBootstrap.java:246)
在作怪.core.server.NettyServer.bind(NettyServer.scala:139)
at play.core.server.NettyServer.play $ core $ server $ NettyServer $$ bindChannel(NettyServer.scala:224)
at play.core.server.NettyServer $$ anonfun $ 1.apply(NettyServer.scala:216)
at play.core.server.NettyServer $$ anonfun $ 1.apply(NettyServer.scala:216)
at play.core.server.NettyServer上的scala.Option.map(Option.scala:146)
。< init>(NettyServer.scala:216)在play.core.server.Netty上
ServerProvider.createServer(NettyServer.scala:279)在play.core.server.NettyServerProvider.createServer(NettyServer.scala:278)
处play.core.server.DevServerStart $$ anonfun $ mainDev $ 1 $ b $。在play.core.server.DevServerStart上应用(DevServerStart.scala:235)
$$ anonfun $ mainDev $ 1.apply(DevServerStart.scala:65)
at play.utils.Threads $ .withContextClassLoader(Threads .scala:64)
。在play.core.server.DevServerStart $ .mainDevHttpMode(DevServerStart.scala::21)在play.core.server.DevServerStart $ .mainDev(DevServerStart.scala
54)
at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java :在作怪62)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java:498)
。 runsupport.Reloader $ .startDevMode(Reloader.scala:234)
at play .sbt.run.PlayRun $$ anonfun $ $ playRunTask 1 $$ anonfun $ $申请2 $$ anonfun $ $申请$ 3.devModeServer lzycompute $ 1(PlayRun.scala:74)
。在play.sbt.run.PlayRun $$ anonfun $ playRunTask $ 1 $$ anonfun $ apply $ 2 $$ anonfun $ apply $ 3.play $ sbt $ run $ PlayRun $$ anonfun $$ anonfun $$ anonfun $$ devModeServer $ 1(PlayRun.scala:74)
at play .sbt.run.PlayRun $$ anonfun $ $ playRunTask 1 $$ anonfun $ $申请2 $$ anonfun $ $申请3.apply(PlayRun.scala:100)
。在play.sbt.run.PlayRun $$ anonfun $ playRunTask $ 1 $$ anonfun $ apply $ 2 $$ anonfun $ apply $ 3.apply(PlayRun.scala:53)
at scala.Function1 $$ anonfun $ compose $ 1.apply(Function1.scala:47)
引起通过:java.lang.NoSuchMethodError:io.netty.channel.DefaultChannelId.newInstance()Lio / netty / channel / DefaultChannelId;

我在build.sbt文件中添加了这样的依赖项。

  libraryDependencies + =com.google.cloud%google-cloud%0.3.0

只有当我添加Google云库时才会发生这种情况。我不确定这是否是图书馆或框架的问题。

解决方案

Google云使用的netty版本与Play使用的netty版本冲突。这会排除Google云的netty而支持Play's。

  libraryDependencies + =(com.google.cloud%google -cloud%0.3.0)。excludeAll(ExclusionRule(organization =io.netty))



然而,如果您尝试使用需要gRPC的功能,它将会失败。详细信息:






有两种解决方案:

A。将google-cloud降级到0.2.2,您可以将工件重命名为gcloud-java:

 com.google。云%gcloud-java%0.2.2



B。降级回放到2.4.6


Here is some of the stack trace

io.netty.channel.ChannelException: Unable to create Channel from class class io.netty.channel.socket.nio.NioServerSocketChannel
at io.netty.channel.ReflectiveChannelFactory.newChannel(ReflectiveChannelFactory.java:41)
at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:318)
at io.netty.bootstrap.AbstractBootstrap.doBind(AbstractBootstrap.java:282)
at io.netty.bootstrap.AbstractBootstrap.bind(AbstractBootstrap.java:246)
at play.core.server.NettyServer.bind(NettyServer.scala:139)
at play.core.server.NettyServer.play$core$server$NettyServer$$bindChannel(NettyServer.scala:224)
at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:216)
at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:216)
at scala.Option.map(Option.scala:146)
at play.core.server.NettyServer.<init>(NettyServer.scala:216)
at play.core.server.NettyServerProvider.createServer(NettyServer.scala:279)
at play.core.server.NettyServerProvider.createServer(NettyServer.scala:278)
at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:235)
at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:65)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:64)
at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:54)
at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at play.runsupport.Reloader$.startDevMode(Reloader.scala:234)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.devModeServer$lzycompute$1(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer$1(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:100)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:53)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
Caused by: java.lang.NoSuchMethodError: io.netty.channel.DefaultChannelId.newInstance()Lio/netty/channel/DefaultChannelId;

I added the depedency like this in my build.sbt file

libraryDependencies += "com.google.cloud" % "google-cloud" % "0.3.0"

This only happens when I add the Google cloud library. I'm not sure if this is a problem with the library or the framework

解决方案

The version of netty that google-cloud uses conflicts with the version of netty that Play uses. This will exclude google-cloud's netty in favor of Play's.

libraryDependencies += ("com.google.cloud" % "google-cloud" % "0.3.0").excludeAll(ExclusionRule(organization = "io.netty"))

However if you try to use a feature which needs gRPC it'll fail. Details:

https://groups.google.com/forum/#!topic/play-framework/UUDZZRpAv3whttps://github.com/playframework/netty-reactive-streams/pull/17

There are two solutions:

A. Downgrading google-cloud to 0.2.2 which you can do by renaming the artifact to gcloud-java:

"com.google.cloud" % "gcloud-java" % "0.2.2"

B. Downgrading Play back to 2.4.6

这篇关于将Google云端客户端库添加到Play 2.5时获取ChannelException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 07:26
查看更多