javaspringspring-bootjerseyweblogic12c

Weblogic + Spring Boot Cloud Eureka Server


I am trying to run a Spring Boot Cloud Eureka server under a Weblogic webserver (Java 8, Weblogic 12, and Spring boot parent 2.4.13). I configured my pom to generate a war file and I am able to deploy but, as soon as it starts I get these errors:

2022-03-03 18:46:34.013 ERROR 5108 --- [ (self-tuning)'] o.s.b.d.LoggingFailureAnalysisReporter   :

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

    org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.jerseyFilterRegistration(EurekaServerAutoConfiguration.java:185)

The following method did not exist:

    com.sun.jersey.spi.container.servlet.ServletContainer.<init>(Ljavax/ws/rs/core/Application;)V

The method's class, com.sun.jersey.spi.container.servlet.ServletContainer, is available from the following locations:

    zip:D:/Development/Domains/lifeGateway/servers/AdminServer/tmp/_WL_user/registrationServer/rh50eu/war/WEB-INF/lib/jersey-servlet-1.19.4.jar!/com/sun/jersey/spi/container/servlet/ServletContainer.class
    jar:file:/D:/Development/Servers/WebLogic12213/wls12213/oracle_common/modules/weblogic.jaxrs.portable.server.jar!/com/sun/jersey/spi/container/servlet/ServletContainer.class

The class hierarchy was loaded from the following locations:

    com.sun.jersey.spi.container.servlet.ServletContainer: file:/D:/Development/Servers/WebLogic12213/wls12213/oracle_common/modules/weblogic.jaxrs.portable.server.jar
    javax.servlet.http.HttpServlet: file:/D:/Development/Servers/WebLogic12213/wls12213/oracle_common/modules/javax.servlet.javax.servlet-api.jar
    javax.servlet.GenericServlet: file:/D:/Development/Servers/WebLogic12213/wls12213/oracle_common/modules/javax.servlet.javax.servlet-api.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of com.sun.jersey.spi.container.servlet.ServletContainer

<Mar 3, 2022 6:46:34,271 PM CET> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "1291493286977307" for task "2" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: java.lang.NoSuchMethodError: com.sun.jersey.spi.container.servlet.ServletContainer.<init>(Ljavax/ws/rs/core/Application;)V"
weblogic.application.ModuleException: java.lang.NoSuchMethodError: com.sun.jersey.spi.container.servlet.ServletContainer.<init>(Ljavax/ws/rs/core/Application;)V
        at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: com.sun.jersey.spi.container.servlet.ServletContainer.<init>(Ljavax/ws/rs/core/Application;)V
        at org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.jerseyFilterRegistration(EurekaServerAutoConfiguration.java:185)
        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:498)
        Truncated. see log file for complete stacktrace
>
<Mar 3, 2022 6:46:34,315 PM CET> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 1 task for the application "registrationServer" on [partition-name: DOMAIN].>
<Mar 3, 2022 6:46:34,327 PM CET> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application "registrationServer".>
<Mar 3, 2022 6:46:34,327 PM CET> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: java.lang.NoSuchMethodError: com.sun.jersey.spi.container.servlet.ServletContainer.<init>(Ljavax/ws/rs/core/Application;)V
        at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: com.sun.jersey.spi.container.servlet.ServletContainer.<init>(Ljavax/ws/rs/core/Application;)V
        at org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.jerseyFilterRegistration(EurekaServerAutoConfiguration.java:185)
        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:498)
        Truncated. see log file for complete stacktrace```

After some investigations, I start to think it is related to the embedded tomcat but, I am not sure. At the moment I am stuck, do you have any idea why I am getting this error? 

These are the dependencies I am including:

```<dependencies>

        <!-- 1. Spring Boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <!-- 2. Spring Boot Starter Cloud -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcprov-jdk15on</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- 3. Spring Boot Starter Web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- 4. Spring Boot Starter Modules -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- 5. Servlet Starter -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>```


Solution

  • I have finally found the issue. There were some dependencies conflicts (in particular Jersey and FasterXml Jackson deps) that must be resolved in order to start the Eureka service under Weblogic.

    So, I have changed the pom.xml in this way:

    <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
    
    <!-- 1. Spring Boot -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    
    <!-- 2. Spring Boot Starter Cloud -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcprov-jdk15on</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>jersey-core</artifactId>
                <groupId>com.sun.jersey</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jersey-client</artifactId>
                <groupId>com.sun.jersey</groupId>
            </exclusion>
            <exclusion>
                <artifactId>woodstox-core</artifactId>
                <groupId>com.fasterxml.woodstox</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/com.netflix.eureka/eureka-client -->
    <dependency>
        <groupId>com.netflix.eureka</groupId>
        <artifactId>eureka-client</artifactId>
        <version>1.10.17</version>
        <exclusions>
            <exclusion>
                <artifactId>jersey-client</artifactId>
                <groupId>com.sun.jersey</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jersey-core</artifactId>
                <groupId>com.sun.jersey</groupId>
            </exclusion>
            <exclusion>
                <artifactId>guava</artifactId>
                <groupId>com.google.guava</groupId>
            </exclusion>
            <exclusion>
                <artifactId>servo-core</artifactId>
                <groupId>com.netflix.servo</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    
    
    <!-- 3. Spring Boot Starter Web -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    
    <!-- 4. Spring Boot Starter Modules -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web-services</artifactId>
    </dependency>
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-cache</artifactId>
    </dependency>
    <dependency>
        <groupId>com.github.ben-manes.caffeine</groupId>
        <artifactId>caffeine</artifactId>
    </dependency>
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    
    <!-- 5. Servlet Starter -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    
    <!-- 6. Resolving conflicts with dependecies -->
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-core</artifactId>
        <version>${com.sun.jersey}</version>
    </dependency>
    
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>${com.sun.jersey}</version>
    </dependency>
    
    <dependency>
        <artifactId>jackson-dataformat-xml</artifactId>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <version>${jackson-dataformat-xml}</version>
        <exclusions>
            <exclusion>
                <artifactId>woodstox-core</artifactId>
                <groupId>com.fasterxml.woodstox</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>${com.fasterxml.jackson}</version>
    </dependency>
    
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${com.fasterxml.jackson}</version>
    </dependency>
    
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>${com.fasterxml.jackson}</version>
    </dependency>
    
    <dependency>
        <groupId>com.fasterxml.woodstox</groupId>
        <artifactId>woodstox-core</artifactId>
        <version>${com.fasterxml.woodstox}</version>
    </dependency>
    
    <dependency>
        <groupId>com.netflix.servo</groupId>
        <artifactId>servo-core</artifactId>
        <version>${com.netflix.servo}</version>
    </dependency>