Awesome
Tutorial for local development with Liberty for Java™
This project provides a walkthrough on how to develop your Liberty application locally while using IBM Bluemix services in the cloud or their local equivalents when available.
If you are not going to follow the tutorial steps but want to quickly get the app deployed in Bluemix, use the Deploy to Bluemix button:
How it works
The sample application uses the following runtime and services:
In this application, the user submits a text for analysis, optionally providing a description. The text is sent to Personality Insights and the results are displayed.
About the code
The application is a simple Java EE web application.
![Architecture](http://g.gravizo.com/g? digraph G { node [fontname = "helvetica"] ui -> liberty liberty -> database liberty -> watsonpi rankdir = LR; database [shape=box style=filled color="%234E96DB" fontcolor=white] watsonpi [shape=box style=filled color="%2324B643" fontcolor=white] } )
-
ui - the user interface source is under src/main/webapp. It is a simple html page using Bootstrap, Handlerbars and jQuery. app.js holds the code to interface the ui with the backend.
-
liberty - the backend exposes one resource through REST, PIResource. It implements GET/PUT/DELETE actions to manage PIEntry. It reads/writes from the database through PIEntryRepository with the database connector obtained from Database. When a new text is submitted (through PUT), it calls Watson Personality Insights and persists the results in the database.
Running the app on Bluemix
If you are only looking to get this app deployed in your Bluemix account, follow these steps otherwise skip to the next section to start the tutorial.
-
Sign up for Bluemix or use your existing account.
-
Download and install the Cloud-foundry CLI tool
-
Clone the app to your local environment from your terminal using the following command
$ git clone https://github.com/IBM-Bluemix/local-liberty-tutorial.git
-
cd
into this newly created directory -
Build the application WAR file with Maven:
mvn package
The command generates the WAR in target/local-liberty-tutorial.war.
- Connect to Bluemix in the command line tool and follow the prompts to log in.
$ cf api https://api.ng.bluemix.net
$ cf login
Note: The services in the following steps may produce warnings when you create them, alerting you that they are not entirely free. Creating and trying this app leaves you well within the limits of your free quota, however, always remain cognizant of your monthly service usage.
- Create the Cloudant service in Bluemix.
$ cf create-service cloudantNoSQLDB Lite cloudant-for-liberty
- Create the Personality Insights service in Bluemix
$ cf create-service personality_insights tiered pi-for-liberty
- Push your app to Bluemix
$ cf push
And voila! You now have your very own instance of the application running on Bluemix.
Tutorial Requirements
- Sign up for a Bluemix Account or use an existing account.
- Download and install the Cloud-foundry CLI tool
- Have your Java EE development environment ready
The tutorial uses:
- Eclipse IDE for Java EE developers Mars.1 4.5.1
- Websphere Application Server Liberty Profile Developer Tools for Mars
- Java 8
- Maven
- Apache CouchDB
- Cloud-foundry CLI
- Git command line
Tutorial Steps
Here we go, follow these steps to get a copy of the application running locally and deployed to Bluemix:
- Import the project into the development environment
- Create a Liberty profile
- Install and configure Apache CouchDB
- Configure the Liberty profile to use Apache CouchDB
- Test Liberty and CouchDB configuration
- Configure Personality Insights
- Test the application locally
- Deploy the application to Bluemix
Troubleshooting
The primary source of debugging information for your Bluemix app is the logs. To see them, run the following command using the Cloud Foundry CLI:
$ cf logs local-liberty-tutorial --recent
For more detailed information on troubleshooting your application, see the Troubleshooting section in the Bluemix documentation.
Privacy Notice
Sample web applications that include this tracking library may be configured to track deployments to IBM Cloud and other Cloud Foundry platforms. The following information is sent to a Deployment Tracker service on each deployment by default:
- Application Name (
application_name
) - Application GUID (
application_id
) - Application instance index (
instance_index
) - Space ID (
space_id
) or OS username - Application Version (
application_version
) - Application URIs (
application_uris
) - Cloud Foundry API (
cf_api
) - Labels and names of bound services
- Number of instances for each bound service and associated plan information
- Metadata in the repository.yaml file
This data is collected from the repository.yaml
file in the sample application and the VCAP_APPLICATION
and VCAP_SERVICES
environment variables in IBM Cloud and other Cloud Foundry platforms. This data is used by IBM to track metrics around
deployments of sample applications to IBM Cloud to measure the usefulness of our examples,
so that we can continuously improve the content we offer to you.
Disabling Deployment Tracking
To disable deployment tracking remove java-metrics-tracker-client dependencies from the pom.xml.