Correct the classpath if both JARs are needed

Viewed 32

I have the following dependencies:

[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

After a spring-boot-starter-parent and spring-cloud uplift the following message appeared after the application start:

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

Since both the artemis-jms-client-all-2.19.1.jar and netty-common-4.1.79.Final.jar is in use and only the netty-common-4.1.79.Final.jar has the necessary method (setInitialValue()) I cannot just remove one of the JARs.

Is there a way to define the order of these? Is this order issue could have come from the uplift? It was more lazy previously?

1 Answers

You have conflicting versions of the same dependency. When you keep your dependencies as they are, this will be only the first of a longer series of troubles to occur.

Try to use an updated version of artemis-jms-client that dependes on the version of netty-common you need. Decide to either skip the netty-common dependency (since it is contained in the artemis-jms-client) or don't use the ...-all-... dependency of artemis-jms-client but rather us a version that uses transitive dependencies and loads the others via maven (or gradle or whatever build system you use).

Reordering classpath to resolve that kind of troubles is really a very delicate procedure I would never recommend to perform on third-party-dependencies.

Related