简体   繁体   English

io.netty.buffer.PooledByteBufAllocator的NoClassDefFoundError

[英]NoClassDefFoundError for io.netty.buffer.PooledByteBufAllocator

I have created a Cassandra Client written with Achilles Object mapping in java (using IntelliJ + Gradle). 我创建了一个用java中的Achilles Object映射编写的Cassandra客户端(使用IntelliJ + Gradle)。 My Client works fine locally in IntelliJ, but throws the exception when deployed in a docker container. 我的客户端在IntelliJ中本地工作正常,但在docker容器中部署时抛出异常。 I am currently stuck with the below exception in my docker container. 我目前在我的docker容器中遇到以下异常。

java.lang.NoClassDefFoundError: Could not initialize class io.netty.buffer.PooledByteBufAllocator at com.datastax.driver.core.NettyOptions.afterBootstrapInitialized(NettyOptions.java:144) at com.datastax.driver.core.Connection$Factory.newBootstrap(Connection.java:903) at com.datastax.driver.core.Connection$Factory.access$100(Connection.java:751) at com.datastax.driver.core.Connection.initAsync(Connection.java:139) at com.datastax.driver.core.Connection$Factory.open(Connection.java:807) at com.datastax.driver.core.ControlConnection.tryConnect(ControlConnection.java:252) at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:201) at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79) at com.datastax.driver.core.Cluster$Manager.negotiateProtocolVersionAndConnect(Cluster.java:1631) at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1549) at com.datastax.driver.core.Cluster.init(Cluster.java:160) at com.datastax.driver.cor java.lang.NoClassDefFoundError:无法在com.datastax.driver.core.NettyOptions.afterBootstrapInitialized(NettyOptions.java:144)com.datastax.driver.core.Connection $ Factory.newBootstrap初始化类io.netty.buffer.PooledByteBufAllocator。 (Connection.java:903)com.datastax.driver.core.Connection $ Factory.access $ 100(Connection.java:751)at com.datastax.driver.core.Connection.initAsync(Connection.java:139)at com .datastax.driver.core.Connection $ Factory.open(Connection.java:807)at com.datastax.driver.core.ControlConnection.tryConnect(ControlConnection.java:252)at com.datastax.driver.core.ControlConnection.reconnectInternal (ControlConnection.java:201)com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79)at com.datastax.driver.core.Cluster $ Manager.negotiateProtocolVersionAndConnect(Cluster.java:1631)at com。位于com.datastax.driver.cor的com.datastax.driver.core.Cluster.init(Cluster.java:160)中的datastax.driver.core.Cluster $ Manager.init(Cluster.java:1549) e.Cluster.connectAsync(Cluster.java:342) at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:317) at com.datastax.driver.core.Cluster.connect(Cluster.java:259) at java.util.Optional.orElseGet(Optional.java:267) at info.archinnov.achilles.configuration.ArgumentExtractor.initSession(ArgumentExtractor.java:186) at info.archinnov.achilles.configuration.ArgumentExtractor.initConfigContext(ArgumentExtractor.java:96) at info.archinnov.achilles.bootstrap.AbstractManagerFactoryBuilder.buildConfigContext(AbstractManagerFactoryBuilder.java:60) at info.archinnov.achilles.generated.ManagerFactoryBuilder.build(ManagerFactoryBuilder.java:38) at com.ds.db.cassandra.AchillesClient.(AchillesClient.java:22) at com.ds.message.RabbitMQMsgClient$1.open(RabbitMQMsgClient.java:114) at org.apache.flink.api.common.functions.util.FunctionUtils.openFunction(FunctionUtils.java:36) e.Cluster.connectAsync(Cluster.java:342)位于com.datastax.driver.core.Cluster.connectAsync(Cluster.java:317)的com.datastax.driver.core.Cluster.connect(Cluster.java:259)在java.util.Optional.orElseGet(Optional.java:267)的info.archinnov.achilles.configuration.ArgumentExtractor.initSession(ArgumentExtractor.java:186)at info.archinnov.achilles.configuration.ArgumentExtractor.initConfigContext(ArgumentExtractor.java) :96)at info.archinnov.achilles.bootstrap.AbstractManagerFactoryBuilder.buildConfigContext(AbstractManagerFactoryBuilder.java:60),位于com.ds.db.cassandra的info.archinnov.achilles.generated.ManagerFactoryBuilder.build(ManagerFactoryBuilder.java:38)。 AchillesClient。(AchillesClient.java:22)at com.ds.message.RabbitMQMsgClient $ 1.open(RabbitMQMsgClient.java:114)at org.apache.flink.api.common.functions.util.FunctionUtils.openFunction(FunctionUtils.java: 36)

But the class, io.netty.buffer.PooledByteBufAllocator which is part of netty-buffer-4.0.56.Final.jar is already part of the classpath. 但是, io.netty.buffer.PooledByteBufAllocator netty-buffer-4.0.56.Final.jar一部分的类netty-buffer-4.0.56.Final.jar已经是类路径的一部分。

When I tried testing thing locally from my Intellij IDE, things are working fine. 当我尝试从我的Intellij IDE本地测试东西时,一切正常。 But after deployment, I am facing this issue in my docker container. 但是在部署之后,我在我的docker容器中遇到了这个问题。

The service is started in my docker container like this: 该服务在我的docker容器中启动,如下所示:

java -server -XX:HeapDumpPath=/opt/ds/srv/diagnostics/msgreader-1589749851-2s89z.heapdump -Xmx614m -Xms614m -XX:MaxMetaspaceSize=126M -XX:+HeapDumpOnOutOfMemoryError -XX:+UseG1GC -XX:CICompilerCount=4 -XX:MaxGCPauseMillis=1000 -XX:+DisableExplicitGC -XX:ParallelGCThreads=4 -Dsun.net.inetaddr.ttl=60 -XX:OnOutOfMemoryError=kill -9 %p -Djava.library.path=/usr/local/lib -Djava.net.preferIPv4Stack=true -Dapp.dir=/opt/ds/sw/apps/msgreader -Dserver.name=msgreader -Dlog.dir=/opt/ds/var/log/msgreader -cp /opt/ds/sw/apps/javacontainer/resources:/opt/ds/sw/apps/msgreader/lib/*:/opt/ds/sw/apps/msgreader/resources:/opt/ds/sw/apps/javacontainer/lib/* com.ds.msg.Server start java -server -XX:HeapDumpPath = / opt / ds / srv / diagnostics / msgreader-1589749851-2s89z.heapdump -Xmx614m -Xms614m -XX:MaxMetaspaceSize = 126M -XX:+ HeapDumpOnOutOfMemoryError -XX:+ UseG1GC -XX:CICompilerCount = 4 -XX:MaxGCPauseMillis = 1000 -XX:+ DisableExplicitGC -XX:ParallelGCThreads = 4 -Dsun.net.inetaddr.ttl = 60 -XX:OnOutOfMemoryError = kill -9%p -Djava.library.path = / usr / local / lib -Djava.net.preferIPv4Stack = true -Dapp.dir = / opt / ds / sw / apps / msgreader -Dserver.name = msgreader -Dlog.dir = / opt / ds / var / log / msgreader -cp / opt / ds / SW /应用/ javacontainer /资源中:/ opt / DS / SW /应用/ msgreader / lib目录/ *中:/ opt / DS / SW /应用/ msgreader /资源中:/ opt / DS / SW /应用/ javacontainer / lib目录/ * com.ds.msg.Server启动

From the above cmd, you can notice the -cp argument mentioning the class path. 从上面的cmd中,您可以注意到提到类路径的-cp参数。 And this path contains netty-buffer-4.0.56.Final.jar . 此路径包含netty-buffer-4.0.56.Final.jar

I later found that netty-all-4.0.51.Final.jar is also part of the class path and this jar also contains the same class file. 我后来发现netty-all-4.0.51.Final.jar也是类路径的一部分,这个jar也包含相同的类文件。 I even tried removing jars, with all possible combination. 我甚至试图去除罐子,所有可能的组合。 But still I am facing the same issue. 但我仍面临同样的问题。

Even in case of multiple versions of a jar file, we should be getting NoSuchMethodError , Can anyone please help me understand the problem. 即使在jar文件的多个版本的情况下,我们应该得到NoSuchMethodError ,任何人都可以帮助我理解这个问题。

I have finally found the answer, the issue is what I guessed in my question. 我终于找到了答案,这个问题就是我在问题中猜到的。 Multiple versions of same jar, had caused the failure. 同一个罐子的多个版本导致了失败。 To find it, I used the following in my gradle file: 为了找到它,我在gradle文件中使用了以下内容:

apply plugin: 'project-report'

And ran, 跑了,

gradle htmlDependencyReport

It will give us a good HTML report on the dependencies Tree. 它将为我们提供关于依赖树的良好HTML报告。 We can even use the below cmd, but it will tough to follow up in a multi module gradle projects 我们甚至可以使用下面的cmd,但很难跟进多模块gradle项目

gradle dependencies

In the HTML report, I found achilles-core module had dependency on netty-buffer-4.0.56.Final.jar and another module had dependency on netty-all-4.0.51.Final.jar . 在HTML报告中,我发现achilles-core模块依赖于netty-buffer-4.0.56.Final.jar而另一个模块依赖于netty-all-4.0.51.Final.jar So when I tried the following for achilles in build.gradle , things were working fine: 因此,当我在build.gradle中尝试以下achilles时,事情进展顺利

 compile(group:'info.archinnov', name: 'achilles-core', version: '6.0.0'){ exclude module: 'netty-buffer' } 

As netty-all-4.0.51.Final.jar already had the classes required for achilles Object mapping, my project started working on deployment. 由于netty-all-4.0.51.Final.jar已经有了achilles对象映射所需的类,我的项目开始进行部署。

Another reason for Failure, even after removing the duplicate jars files from the docker container: (Hard)Restarting the pod, in turn created a new pod, which pulls the same Dockerimage from docker repo. 失败的另一个原因,即使从docker容器中删除了重复的jar文件:(硬)重新启动pod,然后创建一个新的pod,从docker repo中提取相同的Dockerimage。

IntelliJ some how, resolves the PATH issue, when running locally :/ IntelliJ如何在本地运行时解决PATH问题:/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java SparkContext错误:java.lang.NoSuchMethodError:io.netty.buffer.PooledByteBufAllocator - Java SparkContext error: java.lang.NoSuchMethodError: io.netty.buffer.PooledByteBufAllocator Memory 泄漏/发布 object io.netty.buffer.PooledByteBufAllocator 来自 JAR netty-configuration-buffer 过渡使用 - Memory leak/issue of the object io.netty.buffer.PooledByteBufAllocator from JAR netty-buffer transitively used by azure-data-appconfiguration java.lang.NoSuchMethodError:io.netty.buffer.PooledByteBufAllocator.metric()Lio / netty / buffer / PooledByteBufAllocatorMetric; - java.lang.NoSuchMethodError: io.netty.buffer.PooledByteBufAllocator.metric()Lio/netty/buffer/PooledByteBufAllocatorMetric; NoClassDefFoundError:io / netty / util / Timer - NoClassDefFoundError: io/netty/util/Timer Netty-通过PooledByteBufAllocator分配可重用缓冲区的列表 - Netty - Allocating a List of reusable buffers via PooledByteBufAllocator 将Netty直接IO缓冲区累积到CompositeByteBuf - Accumulating Netty direct IO buffer to CompositeByteBuf NoClassDefFoundError和Netty - NoClassDefFoundError and Netty NoClassDefFoundError:io / netty / handler / timeout / IdleStateHandler Datastax DSE Java驱动程序 - NoClassDefFoundError: io/netty/handler/timeout/IdleStateHandler Datastax dse java driver java.lang.NoClassDefFoundError:io / netty / util / concurrent / RejectedExecutionHandlers - java.lang.NoClassDefFoundError: io/netty/util/concurrent/RejectedExecutionHandlers Netty io.netty.buffer.ByteBuf.array()引发异常-直接缓冲区 - Netty io.netty.buffer.ByteBuf.array() throws exception - direct buffer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM