websphere-liberty

Deploying applications to Liberty

Deploying a simple application on the command line

  1. Create a simple servlet:

    package web.example;

    import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

    @WebServlet(”/*”) public class HelloServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getWriter().println(“Hello world!”); } }


  1. Package the application into a Web Archive (.war):

    helloapp.war +- META-INF
    +- WEB-INF
    +- web\example\HelloServlet.class

  2. Add the application to your Liberty server:

    $> mv helloapp.war $WLP_INSTALL_DIR/usr/servers/myServer/apps/

  3. Configure your server.xml to know the application and enable the Servlet 3.1 technology:

    $> cat $WLP_INSTALL_DIR/usr/servers/myServer/server.xml

    servlet-3.1
  4. Start the server:

    $> server start myServer Starting server myServer Server myServer started with process ID 1234.

  5. Check the console.log to verify that the application started, and what URL to find it at:

    $> tail $WLP_INSTALL_DIR/usr/servers/myServer/logs/console.log … [AUDIT ] CWWKT0016I: Web application available (default_host): https://localhost:9080/helloapp/ [AUDIT ] CWWKZ0001I: Application helloapp started in 0.272 seconds.

  6. In a web browser, to go the URL https://localhost:9080/helloapp/ as indicated in the console.log. You should see the message from your servlet:

    Hello world!


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow