简体   繁体   English

将Spring Boot部署到Weblogic时的NoSuchMethodError

[英]NoSuchMethodError when deploying Spring Boot to Weblogic

I've got a Spring Boot application running fine locally via the built in tomcat server but I'm having issues deploying it as a war file in Weblogic 12.2. 我有一个Spring Boot应用程序通过内置的tomcat服务器在本地运行良好但我在将其部署为Weblogic 12.2中的war文件时遇到了问题。 I've followed the "85.1 Create a deployable war file" section of the Spring Boot reference guide to build the war file, created a new Weblogic managed server to host it and followed the deployment install steps on Weblogic but get the below exception when clicking start "servicing all requests" on the deployment. 我按照Spring Boot参考指南的“85.1创建可部署的war文件”部分来构建war文件,创建了一个新的Weblogic托管服务器来托管它,并按照Weblogic上的部署安装步骤进行操作,但在单击时获得以下异常在部署上开始“服务所有请求”。 Any suggestions? 有什么建议么?

Dependencies section of build.gradle: build.gradle的依赖项部分:

dependencies {
    compile fileTree(dir: 'lib', include: '*.jar')
    compile(
        'org.springframework.boot:spring-boot-starter-web:1.5.8.RELEASE',
        'org.springframework.boot:spring-boot-devtools',
        'org.springframework.boot:spring-boot-starter-jdbc',
        'org.springframework.boot:spring-boot-starter-data-jpa',
        'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.2',
        'org.springframework.boot:spring-boot-starter-security',
        'javax.servlet:javax.servlet-api:3.1.0'
    )
    testCompile(
        'org.springframework.security:spring-security-test',
        'org.springframework.boot:spring-boot-starter-test'
    )
    providedRuntime (
        'org.springframework.boot:spring-boot-starter-tomcat'
    )
}

Exception received from Weblogic when clicking start "servicing all requests": 单击开始“为所有请求提供服务”时从Weblogic收到异常:

Caused By: java.lang.NoSuchMethodError: org.springframework.web.context.support.StandardServletEnvironment.initPropertySources(Ljavax/servlet/ServletContext;Ljavax/servlet/ServletConfig;)V
        at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)
        at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:87)
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:162)
        at weblogic.servlet.internal.WebAppServletContext.initContainerInitializer(WebAppServletContext.java:1420)
        at weblogic.servlet.internal.WebAppServletContext.initContainerInitializers(WebAppServletContext.java:1359)
        Loads more weblogic errors here.

My application entry point appears to be okay: 我的应用程序入口点似乎没问题:

@SpringBootApplication
public class Application extends SpringBootServletInitializer implements WebApplicationInitializer {

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

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Add a weblogic deployment descriptor as said in spring-docs . 添加一个weblogic部署描述符,如spring-docs中所述。 Create a file named weblogic.xml and add this code to the xml. 创建名为weblogic.xml的文件,并将此代码添加到xml中。

<?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://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
        http://xmlns.oracle.com/weblogic/weblogic-web-app
        http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
    <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>

Now put the weblogic.xml file into WEB-INF folder so that full path will be WEB-INF/weblogic.xml . 现在将weblogic.xml文件放入WEB-INF文件夹,以便完整路径为WEB-INF/weblogic.xml

Update: Add a empty dispatcher-servlet.xml to WEB-INF/ folder. 更新:将空的dispatcher-servlet.xml添加到WEB-INF/文件夹。

dispatcher-servlet.xml 调度员servlet.xml中

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

And your build.gradle add dependency 并且你的build.gradle添加依赖项

org.springframework.boot:spring-boot-starter-web

Also remove 也删除

providedRuntime (
    'org.springframework.boot:spring-boot-starter-tomcat'
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Spring Boot部署到WebLogic 10.3.6中 - Deploying Spring boot into WebLogic 10.3.6 将基于 Spring Boot 的应用程序部署到 WebLogic 时出现 IllegalArgumentException - IllegalArgumentException when deploying Spring Boot based application to WebLogic 403 Forbidden-在Weblogic中部署Spring Boot应用程序 - 403 Forbidden - Deploying Spring Boot application in Weblogic 将spring boot legacy webapp部署到weblogic 10.3.6服务器 - Deploying a spring boot legacy webapp to a weblogic 10.3.6 server 将Spring Boot部署到Weblogic 10.3时出错-AppMerge流的进程异常 - Error deploying spring boot to weblogic 10.3 - Exception in AppMerge flows' progression 尝试在Spring Boot中发送电子邮件时出现NoSuchMethodError - NoSuchMethodError when trying to send email in Spring Boot 使用 eureka 启动 spring 引导应用程序时出现 noSuchMethodError - noSuchMethodError when starting spring boot application with eureka 在 weblogic 上激活时出现 Spring Boot 应用程序错误 - Spring boot application error when activating on weblogic 将Spring Boot应用程序部署到Weblogic - Weblogic试图将我的主类作为XML资源加载并失败 - Deploying Spring Boot app to Weblogic — Weblogic is trying to load my main class as an XML resource and failing 部署到 WebLogic 时出现“weblogic.application.ModuleException: java.lang.NoSuchMethodError: org.springframework.util.MultiValueMap.addAll” - Getting “weblogic.application.ModuleException: java.lang.NoSuchMethodError: org.springframework.util.MultiValueMap.addAll” when deploying to WebLogic
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM