Developing a JEE REST API on IBM Bluemix

On our latest post we quickly show you how to create a simple web project Get Started with Bluemix

On this post we will create a JEE REST application that will be the base for our next post that we will include a database connection with CRUD(Create, Read, Update and Delete) basic functionalities.

For this project we will create a local Liberty WebSphere so we can test the app before we deploy it into Bluemix. This allow us to have all the required libraries at hand.

We suppose you have already sign-up to Bluemix and install the Bluemix Eclipse plug-in . On this step we will setup the project and add an empty REST service.

1. Create a new WebSphere liberty server

After you have install the Bluemix plugin you can do the following:
– Go to the Servers Tab
– Click right button on the empty space and select new server
– Select WebSphere Application Server
– Select Download and install a new runtime environment, from the liberty profile and choose Liberty Profile V8.5.5.2 Runtime
– Choose the Liberty Profile Extended Package
– Accept the Term and Conditions, then the target installation folder.

2. Create a new dynamic web project

– Go to file -> new dynamic web project
– Create a new project with the target runtime WebSphere Application Server
– Select next, until you get asked to configure web module settings and generate the web.xml and finish

3. Create a JAX-RS POJO class

On this step we will create the basic classes to test the rest services
– Create a new Class that will provide the rest services connection


import java.util.ArrayList;
import java.util.List;

import javax.ejb.Stateless;

import co.at3.peopleadmin.model.Person;

public class PeopleAdminService {

public List<Person> list() {
List<Person> persons = new ArrayList<Person>();
persons.add(new Person(1, "Perez", "Pedro", "Colombia", "Bogotá"));
persons.add(new Person(1, "Perez", "Maria", "Colombia", "Medellín"));
return persons;

public Person find(@PathParam("id") Integer id) {
return new Person(1, "Perez", "Pedro", "Colombia", "Bogotá");

public void create(Person person) {
System.out.println("Create Person : " + person.toString());

public void modify(Person person) {
System.out.println("Modify Person : " + person.toString());

public void delete(@PathParam("id") Integer id) {
System.out.println("Delete Person : " + id);


– Now Create an Application Class that will publish the REST services

public class PeopleAdminApplication extends Application{
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<Class<?>>();
return classes;

– Finally Create the entity class

package co.at3.peopleadmin.model;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

public class Person implements Serializable {

private static final long serialVersionUID = -5256770408245841682L;
private Integer id;

4. Modify the web.xml

On this section we will publish the services using the web.xml

– Modify the web.xml file as follows

<!--?xml version="1.0" encoding="UTF-8"?-->



– Publish fist locally and test that everything is working so far, and then upload to Bluemix and test opening the url ending with “/api/people”, you should see the list of persons on Json format

NOTE:To publish on the local server you have to modify the server.xml and add a new featurejaxrs-1.1