Developing Java EE Applications on Cloud

IBM PureSystem is the solution for building private clouds. These private clouds provide the infrastructure for designing and deploying the middleware required to conform to a full software solution. Once complete, it is then called a Virtual Application Pattern. On the other hand, IBM Rational Application Developer has a comprehensive set of tools to design, develop, deploy and test Java applications directly in IBM PureApplication System and IBM Workload Deployer.

What you will learn…
• How to use RAD to create Java EE applications.
• Connect RAD to a PureApplication.
• Create a Cloud application in RAD.
• Publish the cloud application onto PureApplication.
• Use the Virtual Application Builder in PureApplication to build the Virtual Application Pattern topology.
• Deploy the Virtual Application Pattern from RAD to the private cloud.
What you should know…
• Database and JPA concepts.
• Basic Java EE knowledge.
• Basic concepts of cloud computing.

IBM has a solution that accommodates companies’ needs in the space of cloud computing: IBM PureSystem. This is a family of products that are targeted to provide private clouds to those companies while keeping control within the organization.
IBM PureApplication System (PureApp) is one of the members of this family which takes over the task of abstracting deployment topologies of enterprise applications, called Virtual Application Patterns (VAP). Meaning that it can create middleware resources that can also be reused by other applications, and deploy them in a matter of minutes, as opposed to days or even weeks for traditional deployments.
IBM Rational Application Developer (RAD) is an award-winning Integrated Development Environment (IDE) for Java applications along with integration to other IBM products, like IBM Rational Team Concert and PureApp.

The Scenario

In today’s world, changes are happening really fast. This especially impacts companies when talking about providing or migrating IT infrastructure and applications. Moreover, the procurement of new hardware to accommodate new software needs can sometimes take over the company’s capacity.
This is where cloud computing comes into play. Cloud computing is currently one of the hottest spots in the technology world due to its ease and speed of procuring such “hardware” on demand, meaning cost reduction, agility and flexibility, amongst others.
For the purpose of this article, we are going to discuss the following applications:
• A Java Persistence Architecture (JPA) application that will read the contents of a database hosted in IBM DB2 (DB2).
• A Java Server Faces (JSF) application that will show the contents of the database in a web interface.
• A Cloud Application that will be used to map the Java applications to artifacts that PureApp can understand in order to create the topology to be deployed.
All of this development is performed using IBM Rational Application Developer v9.0 and IBM PureApplication System 1.1 w1500. The middleware configuration is IBM WebSphere Application Server v8.0 and IBM DB2 10.1.

The Applications


This is the application that maps the database to the Object-Oriented world using Java Persistence architecture. JPA is a topic not covered within the scope of this article, so details about it are not shown.
In this JPA application, note that the persistence unit is accessing the database layer using a datasource, which extracts the connection details out of the application and relies on the JPA runtime to find this connection to the database.
It is also worth noting that this datasource is specified in the persistence.xml file, located in the META-INF folder of the Java archive.

Listing 1. Persistence.xml file in the JPA project

<persistence version=”2.0” xmlns=”” xmlns:xsi=”” xsi:schemaLocation=””> 

    <persistence-unit name=”PhoneBook_Project”> 






The <jta-data-source>jdbc/PHONE</jta-data-source> statement in the datasource’s JNDI is used to link the database connection with this JPA project.


This application uses the information extracted by the JPA project from the database in order to show it within a web page using Java Server Faces (JSF) technology.
This application does not handle any connection data. It just uses a data table to show the information provided by the Entity Manager in the JPA that is mapped as a managed bean in the faces-context.xml file.
For the purpose of this article, it is prudent to note that RAD has a set of tools for developing JSF by using drag and drop actions, as well as source editing for those who like to have full control of the code. JSF is not in the scope of this article.


This is the application used to group both JPA and JSF projects and archive them in the standard EAR archive format that, ultimately, will be deployed in a WebSphere Application Server (WAS) in PureApp.
As with the other two projects, this one does not contain either the connection information for the database or any intricacies of WAS or DB2. These details are abstracted in the VAP to be developed in the cloud application.


This is the application that knows how the projects in RAD workspace will be deployed on PureApp. The Enterprise Project (EAR) will be mapped to a component in PureApp that will automatically add a WAS to the topology, thus allowing the addition of the DB2 component to be performed on the Virtual Application Builder in PureApp. Once this modification is done, it will be reflected in the cloud application in the workspace to ensure synchronicity between both RAD and PureApp.
At the end of the exercise, an instance of this VAP will be available for use in the private cloud taking advantage of the facilities PureApp offers implicitly.

The Development

The workspace looks as follows:

Figure 1. Workspace overview before the cloud application

Before creating a Cloud application, we need to create a hosting test environment. For this kind of application, RAD has a Workload Deployer Server adapter available to deploy cloud applications to both IBM Workload Deployer and IBM PureApplication System.
To create a new Workload Deployer Server, open the Servers view in RAD, right click and select New > Server. Choose Workload Deployer from the server’s type list, add the Server’s host name (enter your host name or IP Address of PureApp) and the Server’s name (whatever you wish), then click Next. The wizard will ask for your credentials. Add your user name (PureApp ID) and password, then click on Load descriptor. After a few seconds, the descriptor specific settings are shown. Clicking on Environment Profile presents a new dialog. Select your own Environment Profile from the list and then click OK to close the dialog. In the wizard, Cloud group and IP group will be added automatically (if you have more than one in your PureApp, then you will need to select your Cloud Group or IP Group or both). Once complete, click Finish. Confirm a new Workload Deployer server was added to the Servers view and its state is Connected.
We need a project to hold our cloud application. In RAD, click on File > New > Project… > General > Project and enter a name for your project (PhoneBook_Cloud in our case), then click Finish.
In Enterprise Explorer, right click on the PhoneBook_Cloud project and select New > Other > Cloud Application > Cloud Application. In the Cloud Application wizard, verify PhoneBook_Cloud is selected in the projects list. If not, then select it. File name specifies the file name to a json file which will describe the topology of the application. Enter a name for it. In this article, we will use PhoneBook.json. Now, click Next. In the next page, we will indicate the Workload Deployer to use and the pattern type supported. Thus, verify that your Workload Deployer is selected in the Descriptor combo box. Thereafter, select Web Application Pattern Type 2.0 from the Pattern type list (which suits Java EE 6 or lower applications using WebSphere Application Server 8.0) and then click Next.
The next page maps the projects in your workspace to VAP components. Click on Add to open the New Component and Project Association wizard. Give a name to the component (PhoneBookComp) and select the Enterprise Application project from the list. Press OK to close the dialog and finally click the Finish button.
At this point, the Enterprise Application, PhoneBook_EAR, is already mapped as a component in PureApp. So, we can proceed to publish the application and turn it into a VAP. To publish your Cloud Application, go to Servers view, right click on Workload Descriptor server and select Add and Remove. A new Dialog is opened. Select your Cloud Application (PhoneBook_Cloud) project from Available list and click Add. Confirm PhoneBook_Cloud project now populates Configured list and click Finish. Expand Workload Descriptor Server in Servers view and verify that your application pattern was added as a child, and its state is Stopped, Synchronized.
In Servers view, right click on Workload Descriptor server and select Launch Dashboard. This will launch a Web Browser window with the PureApp Workload console in it. You will need to log in before proceeding.
In PureApp Workload Console, go to Pattern > Virtual Applications and verify PhoneBook appears in Virtual Application Patterns list. Select PhoneBook and look at some of its properties in the right side. Notice that only one component is added in the topology and it’s shown in the thumbnail preview.

Figure 2. Topology preview of the cloud application

Once the cloud application is published and the VAP is created in PureApp, the pattern can be enhanced to provide more functionality than just a WAS server. In this case, we are going to provide a DB2 and a datasource to provide database access to the Enterprise application.
PureApp provides a pattern builder, called Virtual Application Builder. This page consists of three sections: Assets, Editor and Details. Each of them allows you to modify and enhance your cloud experience because it lets you adapt the middleware topology used by your applications. This topology can contain new or existing databases, application servers, user registries, transactional components and more, and you can link them to get an integrated IT infrastructure after you deploy it. The intricacies of configuring host names, ports and so on are done by PureApp on your behalf.
To enhance the application, in the PureApp Workload Console, go to the Virtual Application Patterns page and select your VAP. Click Open so you can get the Virtual Application Builder page. Once the builder page is loaded, expand the Database Components section and drag and drop a DB2 Database component onto the canvas.
In the Details page of the DB2 component, enter a name for the component, a database name and the schema file to create the tables of the database. This schema file should have a .sql extension to be recognized by PureApp as such. This action may take some time depending on the weight of your file and network latency.
Now that WAS and DB2 are configured, we need to make them communicate with each other and create the datasource needed by the application to access the database. To do this, hover on the WAS component until you notice a blue circle on the right side of the component, then drag and drop it onto the DB2 component. This is the link between both middleware components that has the datasource information. In the Details section of the link, specify the JNDI name, Transaction type and JDBC driver. In RAD, you can find the DB2 driver in /plugins/ It may take a while to upload the driver depending on the archive weight and network latency. It is important to note that you need to put your driver’s JAR archive into a ZIP archive so that PureApp can properly load it.
Save your work and close the Virtual Application Builder window. In the Virtual Application Patterns page, you will notice the preview is updated with the new look of the topology. If not, just refresh.

Figure 3. Topology preview of the cloud application modified

Once the VAP topology is done, you can see the new status in the cloud application module published on the server in RAD. It should appear as Reacquire. This means that the VAP was modified externally (on Virtual Application Builder). Right click on the cloud application module and select Reacquire. RAD will then show the changes in the topology. If you select any of the changes, you might run into a situation whereby your local projects are overwritten. Therefore, be careful when selecting your applications. For the purpose of this article, no selection is made, just click Finish.
If you open your cloud application JSON file, you will notice that it has changed according to the changes you made in the Virtual Application Builder.
Now that the cloud application is ready to go, you just need to right click on the cloud application module in the Workload Deployer server in RAD and select Start. After some time, (around 20 minutes) your VAP will be deployed and ready to be used. To verify the progress and status of your Virtual Application Instance, go to PureApplication Workload Console > Instances > Virtual Applications and select your application.

Figure 4. Virtual Application running and showing Endpoints for both middleware

If you click on any of the Endpoints, you will get a URL of that resource within that virtual machine. In the case of WAS, it will give you the HTTP URL of the server. Only then can you complete it with your Context Path to run your application.

Figure 5. Endpoint of WAS HTTP URL information

Now that the cloud application is deployed, you can work with it from the workspace. Once you do a modification in any of the deployed applications, the Server and the affected module will have a Republish state.

Figure 6. Server and module in republish state

Right click on the server and select Publish. This will reflect the changes you’ve done in the RAD’s workspace directly in the application deployed in PureApp. A job in progress dialog may pop up. You can click on Run in background if you wish, so you can still work on your workspace. Note that on this occasion, the republish is quicker because the resources (virtual machine instances) are already created.
Couple of things worth noticing here:
• New middleware is created in the end, meaning that you have dedicated servers for each of your components in your topology, balancing the work between them.
• The intricacies of configuring the datasource were done by PureApp. This, allows you to focus on the business problem instead of the infrastructure.
• The speed of procurement is immensely faster than with traditional hardware or middleware.
• By using RAD, you get rid of the details of PureApp processes; just focus your effort on the domain problem.
• In integrating with RAD, your development and the inclusion of Java EE applications to private clouds is as simple as creating a project, customising it according to your needs (flexibility) and deploying it.


IBM PureApplication Systems make the inclusion of Java applications simple by abstracting the middleware layers through drag and drop actions that simplify and speed up procurement of IT infrastructure.
With RAD, you can use the facilities PureApplication offers to have the development-on-cloud experience in one single solution. Once this exercise is finished, you should be able to use the knowledge acquired to develop a cloud application, or even include existing Java applications, to produce Virtual Application Patterns that can also be used by different Java applications that share a common topology.


On the Web,+Part – Series of articles that showcase PureApplication Systems in many different regards. – IBM PureApplication Systems Information Center. – Try Rational Application Developer for WebSphere. – Learn about PureSystems family
• PureApplication System: An integrated and high-scalable system that provides an application-centric computing model for cloud environments.
• PureApp: An IBM PureApplication System
• IBM Workload Deployer: A hardware appliance that provides software virtual images and patterns for private clouds
• VAP: Virtual Application Pattern
• RAD: IBM Rational Application Developer.
• Datasource: Is the name given to a connection for setting up a database to be accessed from a server.
• JNDI (Java Naming and Directory Interface): Java API for a directory service that allows Java software clients to discover and look up data and objects via a name.
• JDBC (Java Database Connectivity): API for the Java programming language that defines how a client may access a database.
• JSON (JavaScript Object Notation): Text-based open-standard designed for human-readable data interchange for simple data structures and associative arrays.
• JPA (Java Persistence API): Java framework that describes the mapping of relational data from
• Relational Databases as Objects in Java.


About the Author

Victor Sosa is a software engineer in Rational working on on-boarding Rational IDEs to public (IBM SmartCloud Enterprise) and private (IBM PureApplication System) clouds. Follow him on Twitter

Pablo Esparza is a software engineer in Rational focused on web development tools for Rational Application Developer. Pablo is also leading the automated testing for RAD. Follow him on Twitter

Alina Marin is a software engineer in IBM Worklight Studio focused on mobile/web development tools. Contact her on developerWorks

Martin Gonzalez is a computer systems engineering student in an internship program at IBM. He’s focused on automated test environments for Rational Application Developer. Contact him on

Victor Sosa
I'm a software engineer who loves to speak about technology in general
Victor Sosa

Latest posts by Victor Adrian Sosa Herrera (see all)

Alina Marín
I am a software developer with 3 years’ experience that has been part of various global development teams. I like challenges and learning new things.
Alina Marín

Latest posts by Alina Marín (see all)

Pablo Misael Esparza Rivas
I'm a software engineer who like to learn new stuffs. I like to solve puzzles and watch movies and series. I also love to play some sports like soccer or frontenis.
Pablo Misael Esparza Rivas

Latest posts by Pablo Misael Esparza Rivas (see all)

Martin Gonzalez
Passionate software engineer leveraging software engineering, always trying to find the best way to get the work done, providing his best effort in the challenge.
Martin Gonzalez

Latest posts by Martin Gonzalez (see all)