Building a Java EE app on IBM Bluemix Using Watson and Cloudant

Share this post:

Hey Y’all!

Jeff here again and something I am really excited about is Watson is now available for anyone to use in Bluemix!

Today we are going to be building an example app using Java, Cloudant, and Watson.

Ok let’s talk through what this app is going to do before we build it.

Meet Ivy (hello!)

She’s a talent manager at a growing tech startup.

She’s looking for a new hire that would be a good fit on her team but the company is so popular that she has a huge inventory of resumes to sort through. She’s looking for tools to help her, and tools beyond just simple tag filters.

With Watson services she can also start to solve for a problem like, “I’m looking for another developer like “[insert cool employee].”

So in this case, the application can issue queries such as,

“Find me a Developer like Craig Smith”. Then search through all possible candidate and return a ranked list of candidates sorted by highest-to-lowest percentage of personality resemblance. From here, searches can be refined by including technical skills. “Find me a Developer like Craig Smith, and knows Java, C and Python”.

Make sense??

Ok let’s jump right in.

First thing you need to do is clone the github project with some starter code.

git clone

Or download a zip file if you don’t have git installed

Next we need to complete a couple pre-req steps.

Ok once we have all that setup we can start creating our app.

First we need to sign into Bluemix, so open your browser and head on over to We need to login.  Up at the top lets go ahead and click on Catalog.


Scroll down a little and click on Liberty


On the right hand side we need to give our app a name.  Please note that this name must be unique.  Also remember this name as we will need it later…

Click create.


Bluemix will start deploying our app and Bluemix will start our app.

So next we need to add Cloudant and Watson to our app!

So do you that make sure you are in the dashboard and have your app open like the screencap below.  We will then click the “Add A Service” button.


First let’s add Watson.  Scroll down until you find the “User Modeling” Service.  Go ahead and click that.


Again, all we have to do is click “Create” on the right hand side.


Bluemix is going to ask us if we want to restage our app, we should click the “OK” button.  What Bluemix is asking us here is since we made a change to our app, the app needs to be restarted to bind in Watson.


Next, let’s click “Add A Service” again.


This time scroll down to the bottom and choose “Cloudant”.


Then click “Create” on the right hand side.


It is going to ask us to restage our app again, go ahead and click “OK”.


Now we have all our services added.  Let’s go ahead and start getting some data imported.

On the dashboard for the app let’s go ahead and click on Cloudant.


Next, go ahead and click on “Launch”.  What this is going to do is Single Sign us onto our Cloudant account for us.


So let’s pause and explain what Cloudant is.  Cloudant is a No-SQL database that is based on CouchDB.  The big difference between a relationship database and No-SQL database is illustrated below.  In the relationship database you have to have multiple tables to represent the data and have to use SQL and JOIN statements to get data from both tables.  In a No-SQL database which is commonly referred to as a document store database you stores JSON documents/data (as illustrated on the left below).


So back to the demo….

We need to copy some existing data in instead of trying to create it ourselves.  In CouchDB this is called a replication.  It’s just basically making a bunch of API calls for us and copying data.

So let’s go ahead and click  “Add New Database” in the top left.

Let’s choose a name for our database, lets use “talent-manager”.  You can choose something else but remember it for later…


On the left click replication.


Here are 4 really important steps…

  1. Click Remote Database
  2. Enter in the database URL exactley, “” without the quotes.
  3. Under My databases type in “talent-manager” without the quotes.
  4. Click Replicate


It is going to ask us for a password.


We can get this password from Bluemix.  So let’s switch back to our Bluemix tab in the browser. Then click the “Overview” link on the left.


To get the password for Cloudant click “Show Credentials” on the Cloudant tile.


Double click the long gorpy password as show in the screenshot below.  Right click to copy or Control+C on Windows or Command+C on Mac to copy.


Let’s switch back to our Cloudant tab.  We paste the paste in (step 1), and then click “Continue Replication” (step 2).


The copy has started, let’s go ahead and click “Databases” on the top left.


If the replication was successfull it should show 117 documents for the talent-manager DB, is the number is lower, refresh the page, the copy hasn’t finished yet.

Ok now onto the code, let’s launch Eclipse.

In Eclipse, right click on the project’s area on the left.


Under General click existing project into workspace and click next


Next we want to find our project we downloaded from github.  We need to browse to the directory where it is.  Once you find the talent-manager folder, go one more level down into that into a folder called personafusion (as shown below). Click finish.


Next, we need to make a couple code edits…

In src/

Line 10 currently reads like below.

public static final String CLOUDANT_NAME = "";

It needs to be changed to what is below.  This is our Cloudant database name we created.  If you used something other than “talent-manager here” type that in.

public static final String CLOUDANT_NAME = "talent-manager";

Go ahead and save that file and close it.

Next open src/

We need to update our constructor from what is below.

To this.
If you notice we also added 3 global variables as well.

Next we need to update the Watson code as well.  This is located in src/



Ok, so the app is basically done, we need to build our war file now, on the left side in Eclipse, open build.xml.  On the right hand side right click build [default] and then “Run As” and then “Ant Build”.  This will generate our WAR file for us that we will deploy.


In the bottom it should say “BUILD SUCESSFULL”.


The next and last step involves deploy your app to bluemix.  This step requires the Cloud Foundry CLI to be installed (if you haven’t done this yet scroll back up the pre-req’s section above).

If you are on Windows open up the command prompt, if you are on a Mac or Linux open up the terminal.

Type the following.
cf login -a

It will then ask for your username and password that you registered with for Bluemix.There are two important files in this directory.

  1. manifest.yml
  2. webStarterApp.war

We need to edit the manifest.yml file and then we can deploy the app.
Open the file in your favorite text editor or you can use Eclipse as well. The contents of the file are below.

There are two important lines in here, host and name. These values need to be unique and match the app we deployed earlier. In my case the app name is talent-manager-awesome, so my file would then become what is below.

This value comes from Bluemix, lets open the Bluemix dashboard in our web browser again.  In the screenshot below we can just copy the name of the app and paste this into the manifest.yml file.  So don’t copy my apps name exactly as it won’t work, it needs to be your app’s unique name.


Now the final step we need to cd (change directory) in our command prompt or terminal to where the manifest.yml and webStarterApp.war are located.  For me its located at /Users/jsloyer/Downloads/talent-manager-master/personafusion.

cd /Users/jsloyer/Downloads/talent-manager-master/personafusion
cf push

The cf push command pushes our app to Bluemix, a bunch of text will fly bay saying its deploying and eventually it will say the app is starting and then it is up and running.  Bluemix will give you a URL you can access your app at.


Voila!!!!  We created a Java web app using Cloudant and Watson on IBM Bluemix!

Source Code:
Partially complete code –
Complete code – (Don’t cheat and start with this one!)

Feedback is welcome, please contact me on Twitter @jsloyer –

For a video walkthrough of this demo please visit or watch the video below!


This app was developed over the course of 48 hours at an internal hackathon. The developers and designers that worked on this are the following.

  • Jeff Sloyer

IBM Cloud Containers Service - Core Dev Lead

Add Comment

Leave a Reply

Your email address will not be published.Required fields are marked *

Eric Swanson

Jeff – are you going to update this to show the source edits directly in the cloud and the build using cloud-based Git CI integration?


Jeff Sloyer

Hey Eric,

Sorry for the delay on this, I am working on a continuation of this using the built in git tooling (devops services).


Jeff Sloyer

The instructions on how to use the auto-deploy and git hosting through IBM DevOps Services ( is now live.



Hi Jeff Sloyer,
i had followed all the steps that you mentioned in this article .
I came across some things- till final step it working fine.after opening “ ” only i got the problem ,i too got same interface but it didn’t displayed any images or persons below the comparison thing for compare .Where I have to feed that data ?
And One more thing In CloudantDb Have u taken any predefined datasets in database .

Thanks and Regards
Anil Kumar



    Hi Anil,
    Were you able to resolve the issue where images were not showing once the code the deployed successfully.


Name Rich

In Eclipse, what type of project is this?
new -> project -> Dynamic Web Project ??

I am trying to write a Bluemix app which uses Liberty for Java with a Cloudant service.
I just want to write a simple app that displays an html page (like index.html). The app connects to a cloudant DB and reads/writes data.

Thank You


    Jeff Sloyer

    It is actually a generic Java app. You can import it into Eclipse as an existing eclipse project.



Thank you for your help at Interconnect. I was able to rapidly scale out an existing project with Bluemix. I could not have done it without you.
-Daniel from Miracle.


    Jeff Sloyer

    Thanks for the kind feedback Daniel!



This is really cool layout. Has anybody else encountered what I have before? If so, how did you get around it?

I encountered a Linux (ubuntu) package called cf which gave me much grief when I tried to install clound foundry (cf). I had to delete the Linux package. I cannot get the .war built – got stock in the Eclipse build part – with a build fail:
…../BlueMix/talent-manager/personafusion/src/com/ibm/personafusion/ error: class, interface, or enum expected
[javac] private JSONArray cloudant;
….BlueMix/talent-manager/personafusion/src/com/ibm/personafusion/ error: class, interface, or enum expected
[javac] private JSONObject cloudantInstance;
[javac] ^
…..BlueMix/talent-manager/personafusion/src/com/ibm/personafusion/ error: class, interface, or enum expected
[javac] private JSONObject cloudantCredentials;
[javac] ^
….BlueMix/talent-manager/personafusion/src/com/ibm/personafusion/ error: ‘{‘ expected
[javac] public class CloudantClient()
[javac] ^

….BlueMix/talent-manager/personafusion/build.xml:43: Compile failed; see the compiler error output for details.

Total time: 1 second

Anybody encounter this before? How did you get around it?


Michel Reyrolle


I compiled the application under Eclipse and now i am try to deploy the application using cf push. I added the two required services (user modeling (now renamed personality insights, cloudantNoSQLDB) as specified in the demo script above.

The binding to cloudantNoSQLDB fails after successful upload of application war files. Below is my manifest.yml file.

label: cloudantNoSQLDB
plan: Shared
label: personality_insights
plan: “IBM Watson Personality Insights Monthly Plan”
– disk_quota: 1024M
host: MR-talent-manager-awesome
name: MR-talent-manager-awesome
path: webStarterApp.war
instances: 1
memory: 512M
– cloudantNoSQLDB
– personality_insights

any idea??


    Jeff Sloyer

    The name of the personality insights plan has changed from “IBM Watson Personality Insights Monthly Plan” to standard. Sorry about that.



      I have the same problem as Michel Reyrolle above and I cant get it resolved even after making the change you have recommended.Below is my manifest.yml file.

      label: cloudantNoSQLDB
      plan: Shared
      label: personality_insights
      plan: “standard”
      – disk_quota: 1024M
      host: talent-manager-kn
      name: talent-manager-kn
      path: ./webStarterApp.war
      instances: 1
      memory: 512M
      – talent-manager-db
      – personality-insights-talent-manager



Had the same problem but found that the services don’t really match the services I have, probably the same for you.

cf services

will list the services that are in your instance – then you have to put those in the services section and try again..


Shiling Huang

In the starter code you offered for download, you added some .jar files in deb-jar directory. What are the correct places or steps to download them from?




thank’s for this tutorial and the Demo video, but I tried to reproduce this case but I don’t find the service “User Modeling” in the Watson Services ?

Is there another solution ?


    André LAGUERRE

    Resolved… It’s explained in post before…

    “User Modeling” is now renamed “Personality Insights”



hello sir i had just followed the same process in your tutorial and successfully builtin and also deployed successfully but the application is not working it just showing webpage as before deploying into it please let me know how to do.


Einar Karlsen

I got it to work. 3 things in the manifest needs to be changed:

1) The standard plan for personality insights is called “tiered”. You can get from the Bluemix VCAPs file.

2) The path for the war file must be changed to ./output/webStarterApp.war. That’s where the war is really located.

3) The name of the services at the top and the bottom of the manifest must be changed to the names used by the app.
As already mentioned in another comment, you can get the true names by invoking ‘cf services’ or alternatively from the VCAP file.

Here’s my manifest:

Cloudant NoSQL DB-im:
label: cloudantNoSQLDB
plan: Shared
Personality Insights-7r:
label: personality_insights
plan: tiered
– disk_quota: 1024M
host: EinarsTalentManager
name: EinarsTalentManager
path: ./output/webStarterApp.war
instances: 1
memory: 512M
– Cloudant NoSQL DB-im
– Personality Insights-7r



Hello sir, I get this issue when i try to upload the mainfest file via command line and it says:

Using route
Uploading talent-manager-kea…
Uploading app files from: C:UsersammarAppDataLocalTempunzipped-app583602255
Uploading 3.8M, 145 files
Done uploading
Could not find service talent-manager-kea to bind to talent-manager-kea

Pls help I don’t know what to do anymore.



Instead of editing the yml file and adding a randomly created service name it is much easier to rename the service name for db and watson to the ones expected by the yml file meaning
talent-manager-db and personality-insights-talent-manager.
This can be easily done within the Bluemix dashboard via the menu for the related service.


Sok Dina

Hi Jeff Sloyer, it is very nice project, I have tested it. Everything is successful except it doesn’t load data when I test.

could you please advice me something?

More How-tos stories

Deploying to IBM Cloud Private with IBM Cloud Developer Tools CLI

IBM Cloud Private is an application platform for developing and managing on-premises, containerized applications. It is an integrated environment for managing containers that includes the container orchestrator Kubernetes, a private image repository, a management console, and monitoring frameworks.

Continue reading

IBM Cloud Garage Method Field Guide

What does it mean to behave like a startup? How can you transform your business? Field-tested answers to these questions and others are found in the IBM Cloud Garage Method Field Guide. Presented in a fun and visual format, the Field Guide introduces the method and its related practices and architectures that you need to quickly develop quality products.

Continue reading

Hands-on time with IBM Cloud Private

To give you an idea of the IBM Cloud Private environment, the IBM Cloud Garage Method site hosts a hands-on demonstration using actual private servers, allocated on demand for your evaluation. The brief 10 minute demo guides you through the steps of installing a storefront shopping application defined by several Kurbernetes-based microservices. Once installed, you’ll see how to monitor its deployment and running status.

Continue reading