[JBoss] Class Loading conflict using jboss/wildfly when two jars have same set of classes, how...

Discussão em 'StackOverflow' iniciado por Stack, Agosto 12, 2021.

  1. Stack

    Stack Membro Participativo

    I have a war file which is to deployed on jboss/wildfly. The war contains a number of jars in its WEB-INF/lib directory. Some of these jars contain conflicting (or at least different ) versions of the same classes.

    For example, There is a jar of feign which are coming from two sources in our legacy code and defined in maven, so it might be used in one or the other classes and I can't delete any.

    <dependency>
    <groupId>io.github.openfeign</groupId>
    <artifactId>feign-okhttp</artifactId>
    <version>10.1.0</version>
    </dependency>


    which brings Feign Dependency of feign-core:10.2.3

    <dependency>
    <!-- Required to use PATCH -->
    <groupId>com.netflix.feign</groupId>
    <artifactId>feign-httpclient</artifactId>
    <version>8.18.0</version>
    </dependency>


    which brings Feign Dependency of feign-core:8.18.0

    Both has a Response Class but one of them doesn't have a specific create method required by code.

    The question is when jboss/wildfly deploys this war file it will bring all dependencies in WEB-INF/lib folder and both jars are there only, what will be the order/precedence of the jar files here? If classloader picks the first jar, it will throw an error, otherwise it will work correctly.

    In the first case it throws this error:

    java.lang.NoSuchMethodError: feign.Response.create(ILjava/lang/String;Ljava/util/Map;Lfeign/Response$Body;)Lfeign/Response;

    How can we avoid this?

    Continue reading...

Compartilhe esta Página