Home > database >  Weblogic Spring Boot Cloud Eureka Server
Weblogic Spring Boot Cloud Eureka Server

Time:03-08

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

CodePudding user response:

  1. You have to be sure that your target packaging type is war. Check out your pom.xml
  2. Add ServletInitializer
public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringBootWebLogicApplication.class);
    }

}
  1. Add spring-boot-starter-tomcat as provided depedency
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

These should be sufficient.

CodePudding user response:

i think to work with weblogic, there are two files needed to be putted under WEB-INF

  1. weblogic.xml
  2. dispatcherServlet-servlet.xml

the contents of weblogic as following:

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
    xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
    http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">

<wls:context-root>/myweb</wls:context-root>
<wls:container-descriptor>
    <wls:prefer-application-packages>
        <wls:package-name>org.slf4j.*</wls:package-name>
        <wls:package-name>org.springframework.*</wls:package-name>
    </wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>

the content of dispatcherServlet-servlet.xml as following:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

</beans>

enter image description here

  • Related