Posts Tagged wink

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 !


, , , , , ,