Java Enterprise Edition

IBM WebSphere Liberty Profile

 If your project needs a lightweight Java Web application container, then you are in the right place.  This article shows how to use Websphere Liberty Profile as the Servlet container for your webapp.



Obtaining the Distribution File

Distribution Options

See this link to see what is best for your setup: Liberty Repository


Runtime-Only

This project uses the runtime-only version of Liberty Profile: Liberty Profile Runtime

Once you have accepted the license and downloaded the JAR, move the JAR to the Raspberry Pi using your favorite file transfer method.


Installation on Debian Linux (Ubuntu, Raspbian, etc..)

Filesystem Setup

Create a directory for Liberty Profile, as root. I used this command:

sudo mkdir /opt/websphere


Unpack the Distribution File

Issue this command to unpack the distribution file, in the directory that you just created:

sudo java -jar </patt/to/download/>wlp-developers-runtime-8.5.5.2.jar

Then answer the prompts. I took the defaults (press Enter). After the prompts, it takes a bit to unpack that 50MB file on the Pi.

Start the Server

Next start Websphere Libery Profile to create a default server:

sudo <Liberty Profile Home>/bin/server start

The console should print out a message similar to this:

Starting server defaultServer.
Server defaultServer started with process ID 2376.

Now you can visit the default Webshpere Liberty Profile page at

http://localhost:9080

The start command also creates a default server under:

<Liberty Profile Home>wlp/usr/servers/defaultServer/

Once the default server is created, you can place a project's WAR file in the dropins directory.   Web applications are automatically deployed when a WAR file is placed under the dropins directory:

<Liberty Profile Home>/usr/servers/defaultServer/dropins/


Configure Websphere Liberty Profile

Allow Hosts Other than localhost

Add host="*" to the httpEndpoint tag in <Liberty Profile Home>/usr/servers/defaultServer/server.xml if it is not already there.


Websphere Liberty Profile is Now Ready

With the above configuration, Liberty Profile allows access via a network IP address. For example:

http://192.168.1.229:9080

So if a WAR file named photorama.war is deployed to the dropins directory, then (for the example IP) it would be available at:

http://192.168.1.229:9080/photorama



Stopping the Server

Server Stop

When you are ready to stop the server, issue this command:

sudo <Liberty Profile Home>/bin/server stop



Autostart the Server

Starting the Server on Reboot

It helps to start the server automatically when the Raspberry Pi boots.  Below is the script that Linux can use to autostart Webshere Liberty Profile.  Follow this guide to have the Linux's init start a daemon thread that runs the server when the machine reboots.

init.d Script for Websphere Liberty Profile

The init.d script for Websphere Liberty Profile could look like this:

# Document where/how to install JNI!
export JVM_ARGS=-Djava.library.path=/usr/lib/jni

case $1 in
start)
        /opt/websphere-liberty-profile/wlp-8.5.5.5/bin/server start
        ;;
stop)
        /opt/websphere-liberty-profile/wlp-8.5.5.5/bin/server stop
        ;;
restart)
        /opt/websphere-liberty-profile/wlp-8.5.5.5/bin/server stop
        /opt/websphere-liberty-profile/wlp-8.5.5.5/bin/server start
        ;;
esac
exit 0

                


Date Created: 2014-08-13 21:15:48 -0500 (Wed, 13 Aug 2014)





back    |    top