Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Step by Step Java Web Application Development using IBM Bluemix PaaS (Part 1)

DZone's Guide to

Step by Step Java Web Application Development using IBM Bluemix PaaS (Part 1)

· DevOps Zone
Free Resource

The Nexus Suite is uniquely architected for a DevOps native world and creates value early in the development pipeline, provides precise contextual controls at every phase, and accelerates DevOps innovation with automation you can trust. Read how in this ebook.

Terms like cloud, Platform as a Service (PaaS) , Infrastructure as a Service (IaaS), Software as a Service (SaaS) are being mentioned more often then ever nowadays and that is because our informations tend to get stored somewhere else, where can be accessed faster and without high costs of maintenance. We see the clouds in the sky and also our applications can be on a cloud (platform), but why and how is this possible?

Throughout this article you can observe why and how is an advantage to develop or maintain something on a cloud platform, eg Bluemix :

  • Introduction - Cloud Computing and IBM Bluemix™
  • Lesson 1 - Accomodate to the cloud platform IBM Bluemix™
  • Lesson 2 - Develop an web java application written once and run it everywhere
  • Lesson 3 - Continuous Deliver&Build&Deploy using IBM DevOps services
  • Summary

Code is available for download at https://github.com/ammbra/JSPSample

Tutorial requirements consist of :

  • an IBM Bluemix™ account (you can have a free account on https://ace.ng.bluemix.net/)
  • locally, have an IDE ( I used NetBeans but  the Bluemix™ documentation recommends Eclipse IDE)
  • GIT plugin installed within your IDE
  • Java SE 1.6 or higher
  • an application server installed, for testing your code locally, before Bluemix™ delivery. I used Oracle Glassfish 4.0, but if you are free to choose any other server.

Introduction - Cloud Computing and IBM Bluemix™

According to its definition, cloud computing is computing in which large groups of remote servers are networked to allow the centralized data storage, and online access to computer services or resources. Cloud offers the following facilities:

  • agility  through its easy access
  • API accessability to software
  • cost reductions
  • device and location independence
  • easy maintenance
  • performance & productivity
  • reliability
  • scalability and elasticity
  • security

Cloud computing providers exhibit their services according to several fundamental models: SaaS (Software as a Service), IaaS (Infrastructure as a Service) and PaaS (Platform as a Service).


What is Bluemix?

As stated on IBM's official website, IBM Bluemix™ is the newest cloud offering from IBM. Bluemix is a platform as a service (PaaS) offering based on the Cloud Foundry open source project that promises to deliver enterprise-level features and services that are easy to integrate into cloud applications. 

The platform aims to enable organizations and developers multiple manners to create/deploy/maintain applications on the cloud. Bluemix is an implementation of IBM's Open Cloud Architecture based on Cloud Foundry, an open source platform as a service (PaaS). A high level description of Bluemix™ can be found here.

Lesson 1 - Accomodate to the cloud platform IBM Bluemix™

IBM Bluemix™ has a very beautiful catalog of services and through its dashboard allows users to easily connect them. In order to get access to IBM Bluemix™ facilities you will need to have an account. The advantages of having an account are multiple: you have access to Bluemix™, but you also obtain automatic build and deployment from IBM DevOps™ services with every code delivery you make.

There are two approaches to have an application (java application perspective) on IBM Bluemix™  :

  • Approach 1  : you have the application code but you would like to have it running on Bluemix™ using a database service available there. For this approach you should do:
    1. go to https://hub.jazz.net/  and login with your Bluemix™ account 

    2. go to MyStuff and click Create Project button in order to make a project for your application. Select GIT as versioning system and check Bluemix™ deployment when defining your project settings.

      After successfully creating your project you will obtain a GIT url.

    3. in order to make your application visible for build and deployment on Bluemix you will need an manifest.yml file located directly under application root directory. You can code it according to Bluemix™ documentation or you can generate it from here . 

    4. push  your application to the remote repository associated to the previously obtained url.

    5. return to https://hub.jazz.net/, click on your project name and then click build and deploy button.

    6. click ADVANCED button 

    7. click on the settings icon located near Git Repo. If your GIT settings regarding the remote branch (where your code resides) are the same as provided in the form click save.

    8. add the build to the stage in order to obtain automatic deployment 

    9. the application is available on Bluemix since it was pushed at step 3 and with every push to the remote branch, an automatic build & deployment will be associated.

    10. now let's create a service for application by clicking add a service button.

    11. select the service you would like to create, in our case a database service.

    12. click BIND A SERVICE in order to link your service to the previously pushed application.

    13. update the manifest.yml file with the binded service details (services: -        serviceNameHere )

  • Approach 2  : you have not built your application yet, but you would like to have it running on Bluemix™ using a database service available there. For this approach you should do: 

    1.  go to Bluemix™ dashboard and click apps menu item. You will be redirected here:

    2. click on CREATE AN APP button

    3. select from boilerplates or runtimes and name the application as you desire. For this article, I selected the runtime Liberty for Java and created an application for it, but  you can start developing with anything available here.

    4. after creating the application you can make a service for it by clicking ADD A SERVICE button.

    5. select the service you would like to create, in our case a database service.

    6. click BIND A SERVICE button in order to link your service to the previously created application.

    7. in order to start developing your Bluemix™ application, clone  the GIT repository that can be associated to it (if you select add git url link from dashboard main area).

    8. before any development, please update manifest.yml file with the binded service (service:

          - serviceName)

    9. add, commit and push to the remote branch any code changes needed to improve your application

Learn

 

The DevOps Zone is brought to you in partnership with Sonatype Nexus.  See how the Nexus platform infuses precise open source component intelligence into the DevOps pipeline early, everywhere, and at scale. Read how in this ebook

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}