java - 将 Spring Boot 应用程序部署到 Websphere 8.5.5.8

标签 java spring-boot websphere-8

我正在尝试将一个非常基本的 spring boot 应用程序部署到 Websphere 8.5.5.8(使用 IBM J6 VM,在 Java 1.6.0 上)。相同的应用程序适用于 Glassfish,但在 Websphere 上抛出异常。我一直在尝试按照网上的每一个指南来让它工作,但仍然无济于事,有人可以阐明我的错误吗?

异常日志如下:

[8/4/16 9:36:52:031 HKT] 00000094 SystemErr     R   com.ibm.ws.exception.RuntimeWarning: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: Unable to load configuration filesnull
[8/4/16 9:36:52:032 HKT] 00000094 SystemErr     R       at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:433)null
[8/4/16 9:36:52:032 HKT] 00000094 SystemErr     R       at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:719)null
[8/4/16 9:36:52:032 HKT] 00000094 SystemErr     R       at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1177)null
[8/4/16 9:36:52:032 HKT] 00000094 SystemErr     R       at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1382)null
[8/4/16 9:36:52:032 HKT] 00000094 SystemErr     R       at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)null
[8/4/16 9:36:52:032 HKT] 00000094 SystemErr     R       at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:971)null
[8/4/16 9:36:52:032 HKT] 00000094 SystemErr     R       at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:776)null
[8/4/16 9:36:52:032 HKT] 00000094 SystemErr     R       at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1379)null
[8/4/16 9:36:52:032 HKT] 00000094 SystemErr     R       at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2189)null

Websphere 版本信息如下:

Installation
--------------------------------------------------------------------------------
Product Directory        /opt/IBM/WebSphere/AppServer
Version Directory        /opt/IBM/WebSphere/AppServer/properties/version
DTD Directory            /opt/IBM/WebSphere/AppServer/properties/version/dtd
Log Directory            /var/ibm/InstallationManager/logs

Product List
--------------------------------------------------------------------------------
ND                       installed

Installed Product
--------------------------------------------------------------------------------
Name                  IBM WebSphere Application Server Network Deployment
Version               8.5.5.8
ID                    ND
Build Level           cf081545.03
Build Date            11/12/15
Package               com.ibm.websphere.ND.v85_8.5.5008.20151112_0939
Architecture          x86-64 (64 bit)
Installed Features    IBM 64-bit WebSphere SDK for Java
                      WebSphere Application Server Full Profile
                      EJBDeploy tool for pre-EJB 3.0 modules
                      Embeddable EJB container
                      Stand-alone thin clients and resource adapters

我的 POM 文件:

<packaging>war</packaging>

<name>test-server</name>

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

<properties>
    <start-class>com.test.ServletInitializer</start-class>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.6</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
        </plugin>
    </plugins>
</build>

最后是我的主课:

@SpringBootApplication(exclude = MessageSourceAutoConfiguration.class)
public class ServletInitializer extends SpringBootServletInitializer {

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

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

最佳答案

这里的问题看起来像你的 ServletInitializer类是使用与运行 WebSphere 不同的版本编译的。根据this table , WAS 8.5.5.8 随 Java 68 一起提供。

看看你的 pom.xml,你有你的 ServletInitializer使用 Java 7 构建:

<properties>
    <start-class>com.test.ServletInitializer</start-class>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.7</java.version>
</properties>

所以将其降低到 <java.version>1.6</java.version>希望这能解决您的问题。

旁注:
您在 Java EE 7 的 pom.xml 中有一个依赖项,但 WebSphere 传统版在 9.0 版之前不兼容 EE7,因此我建议您提高 javaee-api版本降至 6.0 .

关于java - 将 Spring Boot 应用程序部署到 Websphere 8.5.5.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38755776/

相关文章:

java - java中泛型类中的double方法

java - Spring Batch 3.0.2 与 Spring Core 4.1.x 的集成 - 使用 @EnableBatchProcessing 的合适方法是什么?

java - 未使用 Spring Webflux 路由器功能

java - 如何让spring使用mysql而不是hsql

websphere-liberty - 如何在 NetBeans 8.2 中添加 IBM WAS 8.5

java - log4j2查找websphere环境变量

java - 以编程方式在 Hibernate 中设置数据库 url/用户/密码

java - 如何在不使用 Session 的情况下在 Spring 中将对象从一个 Controller 传递到另一个 Controller

java - Solr 在 Websphere 8.5.5 上部署为 WAR 应用程序

java - 如何将整个文件夹或包从 Java 转换为 Objective-C?