You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenLiberty中企业应用显示运行但访问报404的问题求助

问题描述

尝试部署IBM示例应用libertyDefaultApplicationCLIENT-CERT.ear,server.xml配置如下:

<server description="Sample Liberty server">

  <featureManager>
    <feature>transportSecurity-1.0</feature>
    <feature>adminCenter-1.0</feature>
  </featureManager>
... 
  <variable name="http.port" defaultValue="9080"/>
  <variable name="https.port" defaultValue="9443"/>

  <httpEndpoint httpPort="${http.port}" httpsPort="${https.port}"
      id="defaultHttpEndpoint" host="*" />
      
  <enterpriseApplication location="libertyDefaultApplicationCLIENT-CERT.ear" contextRoot="/test" />
</server>

应用放置在config/apps目录,服务器启动后日志有应用启动记录,AdminCenter显示应用已运行,但访问https://localhost:9443/test时出现404错误:

Error 404: com.ibm.ws.webcontainer.servlet.exception.NoTargetForURIException: No target servlet configured for uri: /test
解决方案
  • 添加Web核心特性
    当前server.xml的featureManager仅包含安全和管理中心特性,缺少Web应用运行必需的Servlet或Web Profile特性,导致Web模块的Servlet无法注册。需添加对应特性,例如:

    <featureManager>
      <feature>transportSecurity-1.0</feature>
      <feature>adminCenter-1.0</feature>
      <feature>servlet-4.0</feature> <!-- 或使用webProfile-8.0等完整Web特性包 -->
    </featureManager>
    

    重启服务器后,Web模块会正确初始化Servlet。

  • 访问应用的具体路径
    直接访问/test可能没有对应的默认Servlet或欢迎页面。查看服务器启动日志,寻找类似CWWKT0016I: Web application available (default_host): https://localhost:9443/test/xxx的条目,其中xxx是应用的可访问具体路径(如index.jsp、HelloWorld等),使用完整路径访问即可。

  • 验证应用内部配置
    解压libertyDefaultApplicationCLIENT-CERT.ear,检查内部Web模块的WEB-INF/web.xml是否配置了默认欢迎页面或Servlet。若Web模块自身配置了context-root,会覆盖server.xml中的设置,需以内部配置的上下文根为准。

  • 查看详细启动日志
    启用更详细的日志输出(如添加logging-1.0特性并设置日志级别为INFO),确认Web模块的注册状态和上下文根信息,排查是否有初始化异常。

内容的提问来源于stack exchange,提问作者Genna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 08:50:59