+

Search Tips   |   Advanced Search

Deploy a web application to the Liberty profile

By deploying a helloworld.war application, we can learn how server configurations change in the Liberty profile.

The helloworld.war application uses a simple servlet to display a message on the browser. We can create any other messages to be displayed. The coding of the application is not described within the Liberty profile documents.

When we deploy a web application to the Liberty profile using the developer tools, all configurations related to the application are automatically enabled in the server.xml file. We can also configure the server.xml file manually by completing the following steps.

This example uses the helloworld.war application and can be accessed using http://localhost:9090/helloworld. In this example, a Liberty profile server instance is created, and then its default HTTP port is changed to 9090, and then an application is deployed to it.

  1. Create a server named hwserver using the command server create hwserver.

  2. Copy the helloworld.war application into the /usr/servers/hwserver/apps directory; this directory was created by the server create command in step 1.

  3. In server.xml that was created by the server create command, change the default HTTP port of the server hwserver to 9090 by replacing the attribute value httpPort="9080" with httpPort="9090":
    <server description="new server">
    
      <!-- Enable features -->
        <featureManager>
          <feature>jsp-2.2</feature>
        </featureManager>
    
        <httpEndpoint id="defaultHttpEndpoint"
          host="localhost"
          httpPort="9090"
          httpsPort="9443" />
    </server>

  4. Configure the application by updating the server.xml in either of the following ways:

    The webApplication element extends the application element to allow a more concise configuration.

    The context-root attribute specifies the entry point of the deployed application. The entry point of a deployed application is determined in the following precedence:

    • context-root in server.xml

    • application.xml, if an EAR application

    • ibm-web-ext.xml, if a web application

    • name of the application in server.xml, if a web application

    • Manifest.MF, if a WAB application

    • Directory name or the file name relative to the "dropins" directory of the Liberty profile

    In an application server server.xml configuration, the application element can contain a context-root tag. This context-root tag is applicable in combination with the tag type="war". For all other application types, the context-root element has no effect.

    It is not possible to override the context-root for either an EAR application, or an EBA application. It is only possible to do an override for a stand-alone war file, or webApplication.

  5. Start the server in foreground using the command server run hwserver.

  6. Test the application at http://localhost:9090/helloworld.

  7. Optional: Stop the server if we don't need it.


Parent topic: Deploy applications to the Liberty profile