【问题标题】:Correct the classpath if both JARs are needed如果需要两个 JAR,请更正类路径
【发布时间】:2022-10-18 06:13:34
【问题描述】:

我有以下依赖项:

[INFO]    +- org.apache.activemq:artemis-core-client:jar:2.19.1:compile
...
[INFO]    |  \- io.netty:netty-common:jar:4.1.79.Final:compile
[INFO]    +- org.apache.activemq:artemis-jms-client-all:jar:2.19.1:compile

spring-boot-starter-parentspring-cloud 提升后,应用程序启动后出现以下消息:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    io.netty.buffer.AbstractReferenceCountedByteBuf.<init>(AbstractReferenceCountedByteBuf.java:50)

The following method did not exist:

    io.netty.util.internal.ReferenceCountUpdater.setInitialValue(Lio/netty/util/ReferenceCounted;)V

The calling method's class, io.netty.buffer.AbstractReferenceCountedByteBuf, is available from the following locations:

    jar:file:/app/lib/netty-buffer-4.1.79.Final.jar!/io/netty/buffer/AbstractReferenceCountedByteBuf.class
    jar:file:/app/lib/artemis-jms-client-all-2.19.1.jar!/io/netty/buffer/AbstractReferenceCountedByteBuf.class

The calling method's class was loaded from the following location:

    file:/app/lib/netty-buffer-4.1.79.Final.jar

The called method's class, io.netty.util.internal.ReferenceCountUpdater, is available from the following locations:

    jar:file:/app/lib/artemis-jms-client-all-2.19.1.jar!/io/netty/util/internal/ReferenceCountUpdater.class
    jar:file:/app/lib/netty-common-4.1.79.Final.jar!/io/netty/util/internal/ReferenceCountUpdater.class

The called method's class hierarchy was loaded from the following locations:

    io.netty.util.internal.ReferenceCountUpdater: file:/app/lib/artemis-jms-client-all-2.19.1.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes io.netty.buffer.AbstractReferenceCountedByteBuf and io.netty.util.internal.ReferenceCountUpdater

由于artemis-jms-client-all-2.19.1.jarnetty-common-4.1.79.Final.jar 都在使用中,并且只有netty-common-4.1.79.Final.jar 具有必要的方法(setInitialValue()),我不能只删除其中一个JAR。

有没有办法定义这些的顺序? 这个订单问题是否可能来自隆起?以前比较懒?

【问题讨论】:

  • artemis-jms-client-all-2.19.1.jar 重新打包该 jar 中的所有依赖项。它包括它需要的所有类。我建议不要使用全部依赖项,只使用核心的一个或单个依赖项。
  • FWIW,ActiveMQ Artemis 2.25.0(即此时的最新版本)使用 Netty 4.1.79.Final。

标签: java spring netty activemq-artemis


【解决方案1】:

您有相同依赖项的冲突版本。当您保持依赖关系不变时,这将只是一系列更长的麻烦中的第一个。

尝试使用取决于您需要的 netty-common 版本的更新版本的 artemis-jms-client。 决定要么跳过 netty-common 依赖项(因为它包含在 artemis-jms-client 中),要么不使用 artemis-jms-client 的 ...-all-... 依赖项,而是使用我们的版本使用传递依赖项并通过 maven(或 gradle 或您使用的任何构建系统)加载其他依赖项。

重新排序类路径以解决此类问题确实是一个非常微妙的过程,我绝不建议在第三方依赖项上执行。

【讨论】:

    猜你喜欢
    • 2018-01-13
    • 2021-10-04
    • 2015-07-06
    • 2016-09-04
    • 1970-01-01
    • 1970-01-01
    • 2015-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多