【问题标题】:Configure two context-root same war file in Webpshere Liberty server在 Websphere Liberty 服务器中配置两个 context-root 相同的 war 文件
【发布时间】:2021-02-05 15:53:22
【问题描述】:

正在将应用程序从 ANT (EAR) 迁移到 Maven (WAR)。在 ANT 项目中,我在 WAR 中有 WEB 层,在 JAR 中有 EJB 层。 EJB 模块有 WebService 代码。现在正在将 ANT 迁移到 Maven 从此应用程序将只有 WAR。在 ANT 中应用时,我可以拥有两个不同的上下文根,例如 "/webapp""/webservice"。在 EJB JAR 归档中定义的上下文根 "/webservice" 如下所示,

<webservices-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ws-bnd_1_0.xsd" 
        version="1.0">
    <!-- optional http publishing module overrides -->
    <http-publishing context-root="/webservice" />
</webservices-bnd>

所以我有不同的 URL 来访问 WEB 和 WebService, http://localhost:9080/webapp/application/index.html - Webapp http://localhost:9080/webservice/service/helloworld?wsdl - 网络服务

根据 IBM 文档 https://www.ibm.com/support/knowledgecenter/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_dep_jaxws_binding.html

当我只有 WAR 文件时,&lt;http-publishing context-root="/webservice" /&gt; 中的

context-root 将不起作用。所以,我只能使用相同的“webapp”上下文根访问 webapp 和 webservice。 但我需要两个不同的 URL 来访问上面的 webapp 和 webservice。我怎样才能做到这一点?

【问题讨论】:

    标签: java maven websphere websphere-liberty


    【解决方案1】:

    如果您将 EAR 文件合并到单个战争中,则无法覆盖该战争中不同端点的默认上下文根。

    您可以使用 Liberty 的 ibm-ws-bnd.xml 配置文件以及您提到的元素:&lt;http-publishing context-root="/webservice" /&gt; 覆盖 EJB jar 的默认上下文根。您需要将您的 EAR 文件与 EJB Web 服务 jar 与您的战争分开打包。

    【讨论】:

    • 是的,我已将 EAR 合并到单个 WAR 中。有什么办法可以在服务器端进行更改以实现此目的。?
    猜你喜欢
    • 2017-07-31
    • 1970-01-01
    • 2015-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多