在Webpshere Liberty服务器中配置两个上下文根相同的war文件

问题描述

正在将应用程序从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-Webservice

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

当我只有WAR文件时,<http-publishing context-root="/webservice" />中的

context-root将不起作用。因此,我只能使用相同的“ webapp”上下文根访问webapp和webservice。 但是我需要两个不同的URL才能访问上述的webapp和webservice。我该如何实现??

解决方法

如果要将EAR文件合并到一个war中,则无法覆盖该war中不同端点的默认context-root。

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