玩转Cassandra Netty Server空指针异常
Play Cassandra Netty Server null pointer exception
嗨,我正在使用 playframework 等技术,
spark = "2.3.1",
akka = "2.4.7"
hadoop = "2.7.7"
spring = "4.2.6.RELEASE",
spark-cassandra-connector 2.0.9 ,
cassandra-driver-core 3.0.6
我在项目清理编译时低于警告
c.d.d.c.NettyUtil - Found Netty's native epoll transport, but not running on linux-based operating system. Using NIO instead
io.netty:netty-handler:4.0.56.Final is selected over 4.0.36.Final
+- com.datastax.cassandra:cassandra-driver-core:3.5.1 (depends on 4.0.56.Final)
+- com.typesafe.netty:netty-reactive-streams:1.0.6 (depends on 4.0.36.Final)
+- io.netty:netty-codec-http:4.0.36.Final (depends on 4.0.36.Final)
在 sbt 运行 时,低于错误
java.lang.NullPointerException
at io.netty.channel.group.DefaultChannelGroup.add(DefaultChannelGroup.java:146)
at play.core.server.NettyServer.bind(NettyServer.scala:140)
at play.core.server.NettyServer.play$core$server$NettyServer$$bindChannel(NettyServer.scala:224)
at play.core.server.NettyServer$$anonfun.apply(NettyServer.scala:216)
at play.core.server.NettyServer$$anonfun.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.apply(DevServerStart.scala:225)
at play.core.server.DevServerStart$$anonfun$mainDev.apply(DevServerStart.scala:61)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:60)
at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
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:497)
at play.runsupport.Reloader$.startDevMode(Reloader.scala:234)
at play.sbt.run.PlayRun$$anonfun$playRunTask$$anonfun$apply$$anonfun$apply.devModeServer$lzycompute(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$$anonfun$apply$$anonfun$apply.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$$anonfun$apply$$anonfun$apply.apply(PlayRun.scala:100)
at play.sbt.run.PlayRun$$anonfun$playRunTask$$anonfun$apply$$anonfun$apply.apply(PlayRun.scala:53)
at scala.Function1$$anonfun$compose.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon.work(System.scala:63)
at sbt.Execute$$anonfun$submit$$anonfun$apply.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$$anonfun$apply.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$$anonfun.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (*:playRun) java.lang.reflect.InvocationTargetException
如何解决网络问题?
是不是版本不匹配的问题??
如果您也在这里提供一些代码(尤其是您初始化 netty 的代码),我可能会更有帮助,但您面临的问题是在非 Linux 中使用 Linux 本机传输系统。
尝试找到你使用 Epoll 的地方,并用所有操作系统都支持的 NIO 替换它们。
如果您 运行 您的应用也在 Linux 上,那么您应该检查是否可以将 Epoll 与 Epoll.isAvailable()
一起使用
此问题与 Cassandra 有关,因此,目前我使用的是阴影版的 cassandra。
出现问题是因为应用程序使用了另一个 netty 版本,所以为了避免冲突,提供了 cassandra 的阴影版本 jar,它将 Netty 类 捆绑在不同的包
下
"com.datastax.cassandra" % "cassandra-driver-core" % "3.1.4"
exclude("io.netty", "*") classifier "shaded"
供参考:https://docs.datastax.com/en/developer/java-driver/3.1/manual/shaded_jar/
另外,您可以使用 dependencyOverrides:
要更改所选版本,请添加覆盖:
dependencyOverrides += "" % "" % ""
参考:https://www.scala-sbt.org/1.x/docs/Library-Management.html#Overriding+a+version
嗨,我正在使用 playframework 等技术,
spark = "2.3.1",
akka = "2.4.7"
hadoop = "2.7.7"
spring = "4.2.6.RELEASE",
spark-cassandra-connector 2.0.9 ,
cassandra-driver-core 3.0.6
我在项目清理编译时低于警告
c.d.d.c.NettyUtil - Found Netty's native epoll transport, but not running on linux-based operating system. Using NIO instead
io.netty:netty-handler:4.0.56.Final is selected over 4.0.36.Final
+- com.datastax.cassandra:cassandra-driver-core:3.5.1 (depends on 4.0.56.Final)
+- com.typesafe.netty:netty-reactive-streams:1.0.6 (depends on 4.0.36.Final)
+- io.netty:netty-codec-http:4.0.36.Final (depends on 4.0.36.Final)
在 sbt 运行 时,低于错误
java.lang.NullPointerException
at io.netty.channel.group.DefaultChannelGroup.add(DefaultChannelGroup.java:146)
at play.core.server.NettyServer.bind(NettyServer.scala:140)
at play.core.server.NettyServer.play$core$server$NettyServer$$bindChannel(NettyServer.scala:224)
at play.core.server.NettyServer$$anonfun.apply(NettyServer.scala:216)
at play.core.server.NettyServer$$anonfun.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.apply(DevServerStart.scala:225)
at play.core.server.DevServerStart$$anonfun$mainDev.apply(DevServerStart.scala:61)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:60)
at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
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:497)
at play.runsupport.Reloader$.startDevMode(Reloader.scala:234)
at play.sbt.run.PlayRun$$anonfun$playRunTask$$anonfun$apply$$anonfun$apply.devModeServer$lzycompute(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$$anonfun$apply$$anonfun$apply.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$$anonfun$apply$$anonfun$apply.apply(PlayRun.scala:100)
at play.sbt.run.PlayRun$$anonfun$playRunTask$$anonfun$apply$$anonfun$apply.apply(PlayRun.scala:53)
at scala.Function1$$anonfun$compose.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon.work(System.scala:63)
at sbt.Execute$$anonfun$submit$$anonfun$apply.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$$anonfun$apply.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$$anonfun.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (*:playRun) java.lang.reflect.InvocationTargetException
如何解决网络问题? 是不是版本不匹配的问题??
如果您也在这里提供一些代码(尤其是您初始化 netty 的代码),我可能会更有帮助,但您面临的问题是在非 Linux 中使用 Linux 本机传输系统。 尝试找到你使用 Epoll 的地方,并用所有操作系统都支持的 NIO 替换它们。 如果您 运行 您的应用也在 Linux 上,那么您应该检查是否可以将 Epoll 与 Epoll.isAvailable()
一起使用此问题与 Cassandra 有关,因此,目前我使用的是阴影版的 cassandra。 出现问题是因为应用程序使用了另一个 netty 版本,所以为了避免冲突,提供了 cassandra 的阴影版本 jar,它将 Netty 类 捆绑在不同的包
下"com.datastax.cassandra" % "cassandra-driver-core" % "3.1.4" exclude("io.netty", "*") classifier "shaded"
供参考:https://docs.datastax.com/en/developer/java-driver/3.1/manual/shaded_jar/
另外,您可以使用 dependencyOverrides:
要更改所选版本,请添加覆盖:
dependencyOverrides += "" % "" % ""
参考:https://www.scala-sbt.org/1.x/docs/Library-Management.html#Overriding+a+version