Deploying a web application to the Liberty profile

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

Before you begin

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

About this task

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

This example uses the helloworld.war application and can be accessed via http://localhost:9090/helloworld. In this example, we create a Liberty profile server instance and change its default HTTP port to 9090, then deploy the application on it.

Procedure

  1. Create a server named hwserver by 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 the server.xml file that was created by the server create command, change the default HTTP port of the server hwserver to 9090 by replacing the attribute setting 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:
    • Fix Pack 8550 Define the application by using a webApplication element:
      <server description="Hello World Server">
      
       <featureManager>
         <feature>servlet-3.0</feature>
       </featureManager>
      
      <httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9090" />
      
      <webApplication contextRoot="helloworld" location="helloworld.war" />
      
      </server>
    • Define the application by using an application element:
      <server description="Hello World Server">
      
       <featureManager>
         <feature>servlet-3.0</feature>
       </featureManager>
      
      <httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9090" />
      
      <application context-root="helloworld" type="war" id="helloworld"
          location="helloworld.war" name="helloworld"/>
      
      </server>

    Fix Pack 8550 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 the server.xml file
    • application.xml, if an EAR application
    • ibm-web-ext.xml, if a web application
    • name of the application in the server.xml file, 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
  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 you don't need it.

Icon that indicates the type of topic Task topic

Terms and conditions for information centers | Feedback


Timestamp icon Last updated: Monday, 21 April 2014
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-nd-iseries&topic=twlp_dep_war
File name: twlp_dep_war.html