【问题标题】:War file generated out of Spring Boot is not getting deployed to Weblogic 12c从 Spring Boot 生成的 War 文件未部署到 Weblogic 12c
【发布时间】:2019-03-09 09:04:22
【问题描述】:

我正在使用 Spring Boot(2.0.5.RELEASE) 构建一个 war 文件以部署到 weblogic 12c 中。我正在按照以下教程进行操作:

https://o7planning.org/en/11901/deploying-spring-boot-application-on-oracle-weblogic-server

但无法在 weblogic 中部署(通过 weblogic 控制台),并出现以下错误:

Message icon - Error Unable to access the selected application.
Message icon - Error java.io.IOException
Message icon - Error weblogic.utils.compiler.ToolFailureException

并且还在管理服务器日志中观察到以下错误:

####<Oct 3, 2018 11:33:46 PM EDT> <Error> <J2EE> <wloki> <AdminServer> <[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <weblogic> <> <> <1538624026936> <BEA-160228> <AppMerge failed to merge your application. If you are running AppMerge on the command-line, merge again with the -verbose option for more details. See the error message(s) below.>

谁能帮我看看我哪里出错了?

我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.springBoot</groupId>
    <artifactId>DemoSpringBoot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>DemoSpringBoot</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

weblogic.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: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>

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

ServletInitializer.java

package com.springboot;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.WebApplicationInitializer;

public class ServletInitializer extends SpringBootServletInitializer 
                             implements WebApplicationInitializer {

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

}

DemoSpringBootApplication.java

package com.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoSpringBootApplication {

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

如果我做错了什么,请告诉我,因为我无法在这方面取得进展。

谢谢。

【问题讨论】:

  • 尝试从 web 依赖中排除 tomcat,因为你在 webkogic 上部署,所以我认为还需要删除 tomcat 依赖
  • 我已将范围指定为“提供”,它告诉不包含与 tomcat 相关的 jar。我不认为这是问题
  • Tomcat 必须排除我相信网络依赖,否则它会与 tomcat 提供的范围冲突
  • 删除dispatcher-servlet.xml。抛弃你的ServletInitializer,让DemoSpringBootApplication 扩展SpringBootServletInitializer。您可能还想检查您的 Weblogic 日志以获取更多信息/错误。
  • 您还需要在属性中提及 Start 类,如 com.springboot.DemoSpringBootApplication 并在 pom.xml 中提及包装为 'war'

标签: java spring maven spring-boot weblogic12c


【解决方案1】:

问题已解决。在 pom.xml 中添加以下属性后:

 <properties>
  ...
  <log4j2.version>2.8.2</log4j2.version>
  ...

现在可以部署到 weblogic 12c。

【讨论】:

  • 我还有一个问题 -> 我有一个主类 (DemoSpringBootApplication.java),并添加了一些日志记录,以验证在将 .war 部署到 weblogic 后我的主类是否正在启动。但看不到我在主类中添加的任何日志
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-12-08
  • 2019-01-28
  • 2018-03-09
  • 2020-11-29
  • 2015-03-10
  • 2018-12-05
  • 1970-01-01
相关资源
最近更新 更多