0% found this document useful (0 votes)
14 views8 pages

Websphere Lib

Uploaded by

Sanath Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views8 pages

Websphere Lib

Uploaded by

Sanath Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

websphere-liberty

#websphere
-liberty
Table of Contents
About 1

Chapter 1: Getting started with websphere-liberty 2

Remarks 2

Examples 2

Installation and Setup 2

Chapter 2: Deploying applications to Liberty 4

Examples 4

Deploying a simple application on the command line 4

Credits 6
About
You can share this PDF with anyone you feel could benefit from it, downloaded the latest version
from: websphere-liberty

It is an unofficial and free websphere-liberty ebook created for educational purposes. All the
content is extracted from Stack Overflow Documentation, which is written by many hardworking
individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official websphere-
liberty.

The content is released under Creative Commons BY-SA, and the list of contributors to each
chapter are provided in the credits section at the end of this book. Images may be copyright of
their respective owners unless otherwise specified. All trademarks and registered trademarks are
the property of their respective company owners.

Use the content presented in this book at your own risk; it is not guaranteed to be correct nor
accurate, please send your feedback and corrections to [email protected]

https://riptutorial.com/ 1
Chapter 1: Getting started with websphere-
liberty
Remarks
This section provides an overview of what websphere-liberty is, and why a developer might want
to use it.

It should also mention any large subjects within websphere-liberty, and link out to the related
topics. Since the Documentation for websphere-liberty is new, you may need to create initial
versions of those related topics.

Examples
Installation and Setup

Download:
To set up WebSphere Liberty, download the latest zip from WASdev.net.

Layout:
Once you have the zip, extract it to any location on your file system. The basic layout of a Liberty
install is the following:

wlp/ # WLP_INSTALL_DIR
bin/ # location of scripts such as 'server'
dev/ # developer resources (APIs, SPIs, and tools)
etc/ # global customizations (server.env or jvm.options)
lib/ # platform runtime environment
usr/ # user directory
servers/ # servers directory
server_name # directory containing all information for a given server
server.xml # (required) primary server configuration file
apps/ # server applications folder
dropins/ # server dropin applications folder
logs/ # server log files

Detailed layout information: Directory locations and properties

Creating, starting, and stopping a server:

Action Command

Create a server server create myServer

Start a server server start myServer

https://riptutorial.com/ 2
Action Command

Stop a server server stop myServer

Note: The server script is located at: $WLP_INSTALL_DIR/bin/server

Read Getting started with websphere-liberty online: https://riptutorial.com/websphere-


liberty/topic/4871/getting-started-with-websphere-liberty

https://riptutorial.com/ 3
Chapter 2: Deploying applications to Liberty
Examples
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!");
}
}

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

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

3. Add the application to your Liberty server:

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

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

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

<server>
<featureManager>
<feature>servlet-3.1</feature>
</featureManager>

<application location="helloapp.war"/>
</server>

https://riptutorial.com/ 4
5. Start the server:

$> server start myServer


Starting server myServer
Server myServer started with process ID 1234.

6. 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):
http://localhost:9080/helloapp/
[AUDIT ] CWWKZ0001I: Application helloapp started in 0.272 seconds.

7. In a web browser, to go the URL http://localhost:9080/helloapp/ as indicated in the


console.log. You should see the message from your servlet:

Hello world!

Read Deploying applications to Liberty online: https://riptutorial.com/websphere-


liberty/topic/7689/deploying-applications-to-liberty

https://riptutorial.com/ 5
Credits
S.
Chapters Contributors
No

Getting started with


1 Andy Guibert, Community
websphere-liberty

Deploying
2 applications to Andy Guibert, Azquelt
Liberty

https://riptutorial.com/ 6

You might also like