Posts Tagged websphere

Java EE Containers and Docker

Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. Given my long history with Java EE, it was natural for me to experiment the installation and deployment of popular Java EE containers using Docker.

Communities and Software vendors did not wait for me, and I discovered many prebuilt containers, ready to use.

The list below references official builds, i.e. the ones created and maintained by the software vendor. (by alphabetical list)

I also built my own Dockerfile for Glassfish.

Feel free to comment this post, I will update the list.  (Official builds only)

Enjoy !

, , , , , , ,

No Comments

WebSphere Liberty Profile Cluster Sharing an In-Memory Data Grid

WebSphere Liberty Profile is a fast, lightweight and simple Java web application container allowing developer to develop, test and deploy applications easily.  In my previous articles, I explained how to install Liberty Profile on Mac and how to develop and deploy your first REST based services.

Liberty Profile is a standalone Java container.  It is not designed to be included in larger deployments based on WebSphere Application Server  ND cells.

However, Liberty Profile can take benefit of a shared persistence engine to store HTTP Session data. This allows two or more independent Liberty Profile instances to share a common user session for web applications.  When one instance fails, the surviving instances can continue to serve user requests as-is nothing happened.

Persistent data store might be a relational database (such as Derby used for development purposes) or a in-memory data grid. In-Memory Data Grid are software solutions providing in-memory data storage, replicated across different containers (or machines). Many IMDG solutions are available from different vendors or in open-source.  Most common ones are MemCached, Terracotta (Software AG), Coherence (Oracle) and IBM’s WebSphere eXtreme Scale.

If you are totally new to eXtreme Scale, I would recommend to read some basic information about its architecture before continuing to read this article.

Configuring WebSphere Application Server (WAS – full profile) to store HTTP Session in a eXtreme Scale container is a matter of three clicks in WAS admin console.  It is slightly more complicate with Liberty Profile, just a few configuration steps described below.

There are four different ways to install eXtreme Scale (XS) with Liberty :

  • Run XS Container in a separate JVM or separate machine than Liberty Profile
  • Run XS Container inside the same JVM as Liberty Profile
  • Use Liberty Profile as client for an XS container
  • Configure Liberty Profile to store HTTP Session data to an XS container

In this article, I will show you how to configure Liberty Profile to

  1. Start an XS server within the same JVM as Liberty profile
  2. Store HTTP Session data in this in-memory data grid,allowing to create clusters of Liberty Profile Instances

My final architecture is depicted in the image below.

0. Download and Install Liberty Profile and eXtreme Scale for Liberty Profile (both solutions are available at no charge from IBM – with forum based and peer-to-peer support only).

  • Liberty Profile installation is described in my previous blog entry.
  • eXtreme Scale for Liberty Profile installation is just a matter of unzipping the file in the directory above wlp

1. Create two servers instances

cd wlpBLOG
sst:wlpBLOG sst$ ./bin/server create ServerONE
Server ServerONE created.
sst:wlpBLOG sst$ ./bin/server create ServerTWO
Server ServerTWO created.

2. Change default HTTP Port in both server.xml so that the two instances can run in parallel

<httpEndpoint host="localhost" httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>

3. Add two features in server.xml for each server.  One to tell Liberty to run an XS server embedded.  And one to tell Liberty to use XS as HTTP Session store for web applications.

<!-- Enable features -->

4. Configure the the WXS container inside Liberty Profile : add WXS configuration in Liberty Profile

<!-- Configuration for XS Server -->
<xsServer isCatalog="true" serverName="XS_ServerONE"/>
<!-- Configuration for Web Application XS HTTP Session data storage -->
<xsWebApp catalogHostPort="localhost:2809"

5. Configure the the WXS container inside Liberty Profile : add XML configuration files in WLP runtime directory

In the directory WLP_HOME/usr/servers/ServerONE, create a “grids” directory and drop those two files

<?xml version="1.0" encoding="UTF-8"?>
<deploymentPolicy xmlns:xsi=""
xsi:schemaLocation=" ../deploymentPolicy.xsd"
<objectgridDeployment objectgridName="session">
<mapSet name="sessionMapSet" numberOfPartitions="47" minSyncReplicas="0" maxSyncReplicas="0" maxAsyncReplicas="1" developmentMode="false" placementStrategy="FIXED_PARTITIONS">
<map ref="objectgridSessionMetadata"/>
<map ref="objectgridSessionAttribute.*"/>
<map ref="objectgridSessionTTL.*"/>


<?xml version="1.0" encoding="UTF-8"?>
<objectGridConfig xmlns:xsi="" xsi:schemaLocation=" ../objectGrid.xsd"
<objectGrid name="session" txTimeout="30">
<bean id="ObjectGridEventListener" className=""/>
<backingMap name="objectgridSessionMetadata" pluginCollectionRef="objectgridSessionMetadata" readOnly="false" lockStrategy="PESSIMISTIC" ttlEvictorType="LAST_ACCESS_TIME" timeToLive="3600" copyMode="COPY_TO_BYTES"/>
<backingMap name="objectgridSessionAttribute.*" template="true" readOnly="false" lockStrategy="PESSIMISTIC" ttlEvictorType="NONE" copyMode="COPY_TO_BYTES"/>
<backingMap name="objectgridSessionTTL.*" template="true" readOnly="false" lockStrategy="PESSIMISTIC" ttlEvictorType="LAST_ACCESS_TIME" timeToLive="3600" copyMode="COPY_TO_BYTES"/>
<backingMapPluginCollection id="objectgridSessionMetadata">
<bean id="MapEventListener" className=""/>

6. Tell Liberty’s session manager to reuse the same session ID for all user’s requests, even if handled by different JVM (See Liberty’s documentation for more details)

<httpSession idReuse="true"/>

7. Start Liberty Profile

sst:wlpBLOG sst$ ./bin/server start ServerONE
Server ServerONE started with process ID 11769.

In the logs, wait for the following line

[AUDIT ] CWWKF0011I: The server ServerONE is ready to run a smarter planet.

8. Create & Deploy a simple JSP file for testing

Create a Dynamic Web Project in Eclipse, and add the following index.jsp page

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Liberty Profile Cluster Demo</title>
<h1>Liberty Profile - eXtreme Scale HTTP Session Demo!</h1>
Integer count;
Object o = session.getAttribute("COUNT");
if (o != null) {
count = (Integer) o;
count = count + 1;
} else {
count = 1;
session.setAttribute("COUNT", count);
<h3>This counter is increased each time the page is loaded.  Its value is stored in the <code>HttpSession</code></h3>
<h3><font color="#FF0000">Counter = <%=count%></font></h3>
<h4>Page server by cluster instance : <font color="#FF0000"><b><%= System.getProperty("") %></b></font></h4>
Page generated at = <%=new java.util.Date().toString()%><br/>

Then deploy the WAR to the server instance (example of creating a WAR and deploying it to Liberty is given in my previous blog post)

9. Test, open your favorite browser and connect to http://localhost:9080/

You should see the following screen

Each time you will refresh the page (CTRL-R), the counter should be increased by one

Congrats, you have your first instance up and running, let’s now configure a second instance.

Repeat Steps 2-7 on a second Liberty instance to create a second cluster member.  Remember to change the following

  • The name of the instance
  • The HTTP and HTTPS ports used by Liberty Profile (step 2 above)
  • The WXS configuration – only one catalog server is needed (step 3 above, change isCatalog=”no”)
  • You do not need to copy the XML files in the grids directory of the second instance (step 5) – This is only required on the instance running XS’ Catalog Server

Then deploy your test application to instance #2.  To test your application, point your browser to

http://localhost:9081/<YOUR APPLICATION NAME>

You should see a page similar to the one shown at step 9 above.  Try to alternatively reload the page from ServerONE and the page from ServerTWO : you should see the session counter to increase in a sequence across the two server instances.

You’ve just created your first Liberty Profile cluster with two instances and a shared in-memory grid for HTTP session storage.

I leave you as an exercise to install and configure a load balancer in front of these two instances.  Hint : I am using the open-source balance for demo / test purpose.

If you find errors / typos in this (long) article, let me know – I will fix them – Thanks !

Enjoy !


, , , , ,

No Comments

How to deploy REST based web services to Liberty Profile ?

In my last blog entry I described how to install Liberty Profile and to configure an Eclipse based development environment.  In this entry, I will show you how to develop & deploy a “Hello World” complexity REST based web service.

Official JAX-RS / Liberty profile is available on IBM Documentation web site.  When developing or debugging REST based services, it is always good to know that IBM’s WebSphere Liberty profile is using Apache’s Wink implementation behind the scene.

Unlike some other Java based application servers (this one and this one for example), WebSphere Liberty Profile does not perform many under covers magical for you, in particular it does not register an application context, you will need to write (one line of) code to do that.

That being said, the process is quite similar for every application server and IDE :

1. Create a web based project


Choose a Project Name, select the runtime for deployment and uncheck the “Create EAR” option

2. add a POJO class that will serve as “resource”

Select a package name and class name.

Type the following code :

public class Demo extends {

    private UriInfo context;

    public String getXml() {
        return "<xml>Hello Rest World !</xml>";

    public void putXml(String content) {

3. add your business code for the PUT and GET methods

4. Before deploying – Add JAX-RS “feature” to your server configuration

This will tell the Liberty kernel to load the JAX-RS server side implementation. You do not need to restart your server when adding / removing features.

5. Deploy and Test

At this stage, Eclipse’s browser will open on the application default URL and will display an error message.  This is normal as we did not define a landing page or default servlet in this project (index.jsp or index.html) for example.

To access the REST web service, use this URL pattern :

http://<hostname>:<port number>/<project name>/<application path>/<path>

which translates for this example to



Et voilà, you just created, deployed and tested your first REST based web service on WebSphere Liberty Profile.

Enjoy !


, , , , , ,


How to install WebSphere 8.5 Liberty profile on Mac

WebSphere 8.5 Liberty Profile is a small, fast, agile WebSphere runtime that you – developers – can use to develop, test or embed in your applications.  The runtime is provided free of charge from IBM.  Like every Java EE Profile, it implements a subset of the Java EE Specification, while ensuring 100% “upwards” fidelity to the full WebSphere Application Server.

On my i7 – quad core – machine, WAS Liberty starts in less than 1 sec.  With not application deployed.

Installing the runtime is as easy as unzipping a file on your drive, here are the steps

  1. download from (46 Mb only)
  2. unzip
    java -jar wlp-developers-

    After displaying and approving the distribution license, you will be ready for the next step

  3. Optional : create a server instance (an instance “defaultServer” is created for you automatically, this step is optional)
    # cd wlp
    # chmod u+x bin/server
    # ./bin/server create MyInstance
    Server MyInstance created.
  4. start it
    # ./bin/server start MyInstance

    Or just this line to start the default instance

    #./bin/server start
    Server MyInstance started with process ID 59946.

Now that you have the runtime, you are ready to install the tooling to manipulate it from Eclipse.

  1.  Start Eclipse (Indigo or Juno)
  2. Open Eclipse MarketPlace
  3. Search for “liberty” and click on “Install”
  4. In the “Eclipse” menu, click on “Preferences”
  5. In the “Preferences” pane, select “Server”, then “Runtime Environment” and click on “Add”
  6. Select “WebSphere Application 8.5 Liberty Profile”
  7. Give the name you want, point to your Installation directory (see bullet 2 in the installation instructions above) and click “Finish”
  8. Switch to the “Server” window in the “Java EE” perspective
  9. Right-click – New -> Server, choose your newly created runtime instance
  10. Don’t leave the “Server” window, right click on the server name and choose “Start”

The “Console” window should automatically open, and within a few seconds, you should see the following line to appear :

Launching default (wlp- on Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_07-b10 (en_US)
[AUDIT   ] CWWKE0001I: The server default has been launched.
[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications. 
[AUDIT   ] CWWKF0011I: The server default is ready to run a smarter planet.

You have now a fully functional WebSphere Liberty profile installed and the corresponding tooling in Eclipse.  The tooling allows you to stop/start the application server, but also to manage its configuration and, obviously, to deploy applications on it.

In the next blog entry, I will show you how to deploy a REST based web service on Liberty

Enjoy !

, , , ,


WebSphere Application Server – Liberty Profile

When talking to developers about WebSphere Application Server Liberty Profile (the new lightweight, ultra fast and developer friendly profile for WAS), I always receive questions about supported JSRs and comparison with Java EE 6’s Web Profile.

Therefore I collected information from documentation, blogs, internal IBM forums etc … to create the following list.

(click to enlarge :-) )

This is *not* an official IBM document, just a compilation I gathered from various sources.  Please feel free to point me any missing or incorrect entries.


The official list of API supported in Liberty profile is now published in WAS 8.5 product documentation.


Enjoy !

, , , ,

No Comments

IBM Software Portfolio – the big picture

Click to enlarge the picture :-) !


No Comments