【问题标题】:Spring-based web application fails at startup on WAS Liberty基于 Spring 的 Web 应用程序在 WAS Liberty 上启动时失败
【发布时间】:2018-09-30 05:36:49
【问题描述】:

我正在编写一个简单的基于 Spring 的 Web 应用程序并将其部署到 Websphere Liberty 8.5.5.9。部署失败,因为应用程序启动失败。 console.log中的消息是

[ERROR   ] CWWKZ0002E: An exception occurred while starting the application userSetting.
           The exception message was: com.ibm.ws.container.service.metadata.MetaDataException:
           com.ibm.wsspi.adaptable.module.UnableToAdaptException:
           com.ibm.ws.javaee.ddmodel.DDParser$ParseException: CWWKC2262E: The server is
           unable to process the 3.1 version and the http://xmlns.jcp.org/xml/ns/javaee namespace
           in the /META-INF/web-fragment.xml deployment descriptor on line 23.

消息的最后一部分现在很有意义,因为我在应用程序的 Eclipse 项目中没有 /META-INF/WEB-INF,因为我正在使用 Gradle 进行部署:gradle clean build deploy

我尝试了对项目的各种修改,无奈之下,我将其缩减为只有以下源代码:

@SpringBootApplication
public class UserSettingApplication {

  private static final LoggerUtils logger = new LoggerUtils( UserSettingApplication.class );

  public static void main(String[] args) {
    logger.debug( "Entering UserSettingApplication.main()" );
    SpringApplication.run(UserSettingApplication.class, args);
  }
}

你能告诉我如何解决这个服务启动问题吗?

server.xml:

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

    <!-- Enable features -->
    <featureManager>
        <feature>jsp-2.2</feature>
    </featureManager>
    <featureManager>
      <feature>adminCenter-1.0</feature>
    </featureManager>

   <!-- Define the host name for use by the collective.
        If the host name needs to be changed, the server should be
        removed from the collective and re-joined. -->
   <variable name="defaultHostName" value="localhost" />

    <!-- Define an Administrator and non-Administrator -->
   <basicRegistry id="basic">
      <user name="admin" password="********" />
      <user name="nonadmin" password="***********" />
   </basicRegistry>

   <!-- Assign 'admin' to Administrator -->
   <administrator-role>
      <user>admin</user>
   </administrator-role>

   <keyStore id="defaultKeyStore" password="*******" />

    <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
    <httpEndpoint id="defaultHttpEndpoint"
                  host="*"
                  httpPort="9080"
                  httpsPort="9443" />

        <!-- Automatically expand WAR files and EAR files -->
        <applicationManager autoExpand="false"/>
</server>

【问题讨论】:

  • 你能用你的 server.xml 更新你的问题吗?我怀疑你没有启用servlet-3.1 功能
  • 添加了 server.xml;和/但是,我能够使用同一台服务器成功部署另一个基于 Spring 的 Web 应用程序。

标签: spring websphere-liberty


【解决方案1】:

此错误似乎是由您的某些构建工具生成的带有 Servlet 3.1 架构的 web-fragment.xml 引起的。

目前,您已启用jsp-2.2 功能,默认情况下启用servlet-3.0

要解决此问题,我建议从 jsp-2.2 升级到 jsp-2.3(这将引入 servlet-3.1),或者添加 &lt;feature&gt;webProfile-7.0&lt;/feature&gt; 以启用所有 Java EE 7 Web 配置文件功能(servlet、 JPA、bean 验证、cdi、jsf 等)。

所以你的新 server.xml 可能如下所示:

<server description="new server">

    <!-- Enable features -->
    <featureManager>
      <feature>jsp-2.3</feature>
      <feature>adminCenter-1.0</feature>
    </featureManager>

<!-- rest of file unchanged.... -->

【讨论】:

  • 安迪,在尝试您的建议之前,我从成功运行的项目中重新复制了我的build.gradle,现在我的项目也成功启动了。我不确定是什么具体的改变促成了这一点,但我会接受它......
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-10-07
  • 1970-01-01
  • 2017-05-12
  • 2019-02-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多