user3410249
user3410249

Reputation: 181

Configure two context-root same war file in Webpshere Liberty server

Am migrating application from ANT (EAR) to Maven (WAR). In ANT project I have WEB layer in WAR and EJB layer in JAR. EJB module has WebService code. Now am migrating ANT to Maven Henceforth application will have only WAR. When application in ANT I can have the two different context-root like "/webapp" and "/webservice". The context-root "/webservice" defined in EJB JAR archive like below,

<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>

So I have different URL to access WEB and WebService, http://localhost:9080/webapp/application/index.html - Webapp http://localhost:9080/webservice/service/helloworld?wsdl - Webservice

As per IBM documentation https://www.ibm.com/support/knowledgecenter/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_dep_jaxws_binding.html

context-root in <http-publishing context-root="/webservice" /> will not work when I have only WAR file. So, I can only access webapp and webservice using same "webapp" context-root. But I need two different URL to access webapp and webservice like above. How can I achieve this.?

Upvotes: 0

Views: 870

Answers (1)

Thomas Johnson
Thomas Johnson

Reputation: 116

If you're combining your EAR file into a single war, then there is no way override the default context-root of different endpoints in that war.

You can override the default context-root for an EJB jar using Liberty's ibm-ws-bnd.xml configuration file, along with the element that you mentioned: <http-publishing context-root="/webservice" />. You'd need to keep your EAR file with the EJB Web Service jar packaged separately from your war.

Upvotes: 1

Related Questions