1

i tried to create Maven project for WAS Liberty server.

mvn archetype:generate -DarchetypeGroupId=net.wasdev.wlp.maven -DarchetypeArtifactId=liberty-archetype-ear -DarchetypeVersion=2.2 -DgroupId=com.test -DartifactId=test -Dversion=1.0-SNAPSHOT

Can you please tell me how to configure Context path and how to add the virtual-host.

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
Suresh Babu
  • 25
  • 1
  • 2
  • 8

1 Answers1

0

Though the archetype template doesn't specifically provide a method for configuring these, you can easily start from the application and server config generated and configure the server "normally" from there.

Example using liberty-archetype-webapp archetype:

  1. Generate project:

    mvn archetype:generate -DarchetypeGroupId=net.wasdev.wlp.maven -DarchetypeArtifactId=liberty-archetype-webapp -DarchetypeVersion=2.5 -DgroupId=com.test -DartifactId=test -Dversion=1.0-SNAPSHOT
    
  2. Create bindings file: src/main/webapp/WEB-INF/ibm-web-bnd.xml with contents:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-bnd
        xmlns="http://websphere.ibm.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://websphere.ibm.com/xmk/ns/javaee   http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
        version="1.0">
    
        <virtual-host name="myVHost" />
    </web-bnd>
    
  3. Configure virtual host (and context root) in server config at src/main/liberty/config/server.xml:

    <server description="Sample Servlet server">
    
       <featureManager>
         <feature>jsp-2.3</feature>
       </featureManager>
    
      <httpEndpoint host="*" httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
    
      <virtualHost id="myVHost">
        <hostAlias>myDomain.myHost.com:9080</hostAlias>
      </virtualHost>
    
      <webApplication id="test" location="test.war" name="test" contextRoot="ctxRoot"/>
    
     </server>
    

Note:

I noticed you specifically asked about the liberty-archetype-ear archetype, so if the above doesn't meet your needs, please comment and mention this.

Also I upgraded the archetype version to 2.5, which also brings in a newer version of Liberty (actually Open Liberty), though it should also be fine at the 2.2 level.

You can

Scott Kurz
  • 4,985
  • 1
  • 18
  • 40