Before you start
IBM® Rational® Application Developer helps Java developers quickly develop and deploy Java, Java Enterprise Edition (Java EE), Open Services Gateway initiative (OSGi), Service Component Architecture (SCA), portal, and web applications. It provides robust tooling to support commonly used application servers and includes development use versions of the latest IBM® WebSphere® Application Server. Additionally, Rational Application Developer supports development with industry standard databases, such as IBM® DB2®, and source control systems, such as IBM® Rational Team Concert™.
The IBM Workload Deployer, the successor to the WebSphere CloudBurst Appliance, also enables deployment of virtual application patterns augmented with performance, load balancing, and scaling policy options. It uses predefined middleware patterns to simplify configurations within a cloud environment.
With the addition of Workload Deployer-specific tools within Rational Application Developer, you can define and develop web, Java EE, and OSGI applications components of a virtual application pattern and manage creation, deployment, and removal of the cloud application artifacts directly from the development environment.
What developers can learn from this article
This article demonstrates common functionality in the new IBM Workload Deployer appliance to build, deploy, and run a simple end-to-end cloud application on Workload Deployer. You will learn how to create a Workload Deployer definition, build and acquire a cloud application, associate Java EE content with the application, and deploy to Workload Deployer. The article also explains how to work with Workload Deployer-provisioned databases.
There are several reasons why your organization could benefit from moving to Workload Deployer for enterprise application development:
- Cost savings for an organization that uses provisioned WebSphere Application Server and DB2 images through Workload Deployer over multiple dedicated WebSphere and DB2 servers
- Rapid and self-service provisioning of resources when dedicated servers are unavailable
- Access to reusable application patterns to simplify construction and deployment
- Standardized management of and access to images and virtual systems
Before starting the example in this article, you will need the following configuration:
- IBM Rational Application Developer for WebSphere Software, Version 8.0.3 or later, with the following features installed on your workstation:
- IBM Workload Deployer development tools
- Java EE and web services development tools
- WebSphere Application Server Version 7.0 development tools
- Tools for developing applications without a local server installation
- IBM Workload Deployer v18.104.22.168 or later with at least one cloud group defined
Set up your workspace
Start Rational Application Developer with a new workspace and with the Java EE perspective open. We will begin by creating a simple project to hold a cloud application, and import a sample application for deployment.
Create a new project:
- Launch the New Project Wizard (right-click in the Enterprise Explorer view and select New > Project).
- Select General > Project, and click Next.
- Name the project
CloudApplication, and click Finish.
- Optionally, enable the validation builders, because they are set to Off by default for general projects. Then right-click the CloudApplication project, select Properties, and then choose these options:
- Select Enable project specific setting.
- Select Add Validation Builder to project.
- Click OK.
Import and prepare the Enterprise JavaBean (EJB) application that you will be deploying to Workload Deployer:
- Download the SurveyEJBEAR.zip file (see the Downloads section in this article).
- Launch the Import Wizard (right-click in the Enterprise Explorer view, and select Import > Import).
- Select General > Existing Projects into Workspace and click Next.
- Select the radio button for Select archive file and browse to find the SurveyEJBEAR.zip file.
- Select all projects, and click Finish.
Workload Deployer does not automatically generate EJB deployment code.
- Generate deployment code for the EJB project (right-click SurveyEJB in the Enterprise Explorer view, and select Java EE > Prepare for Deployment).
Your workspace and sample application should now be properly set up.
Figure 1. Workspace projects after preliminary setup
Create a new Workload Deployer server configuration
Now you need to create a server configuration for Workload Deployer so that Rational Application Developer can communicate with Workload Deployer:
- Launch the New Server wizard (right-click in the Servers view, and select New > Server).
- Select Workload Deployer.
- Enter the IP address or hostname of Workload Deployer in the "Server’s host name" field, and click Next.
Figure 2. Select Workload Deployer and enter the IP address
- Enter the username and password for your Workload Deployer user in the corresponding fields.
- Select a cloud group (click Select and choose a cloud group from the list).
- Click Finish.
If there are no cloud groups listed, you can configure one in Workload Deployer if your permissions allow, or you can contact your Workload Deployer administrator.
You should now see the Workload Deployer listed in the Servers view, as shown in Figure 3.
Figure 3. Workload Deployer in the Servers tab
Create a virtual application pattern using the dashboard
Next, you will create a virtual application pattern. This pattern is necessary to define what specific components your application requires when deployed to the cloud and what content will be included in each of those components.
- Launch the Workload Deployer dashboard by right-clicking the newly created Workload Deployer configuration in the Servers view, and selecting Launch Dashboard.
- A browser window will launch and display a login screen for the dashboard. Enter your Workload Deployer user name and password, and click Login.
- From the toolbar at the top of the dashboard, select the triangle icon (downward arrow) next to Patterns and then select Virtual Applications.
Figure 4. Selecting Patterns > Virtual Application from toolbar
- Click the + [plus sign] icon to add a new pattern.
- Select Blank application as the type, and click Start Building.
Figure 5. Start building a new virtual application
- Add the Enterprise Application component:
- Enterprise Application – WebSphere Application Server
- From the Application Components drawer, drag an Enterprise Application component into the diagram.
- Enterprise Application – WebSphere Application Server
Figure 6. Add an Enterprise Application component
- Add the database component:
- Database – DB2
- From the Database Components drawer, drag a Database component into the diagram.
- Select the Database component in the diagram, and set the Database Name field to
- Upload the Survey.sql file included in a zipped file in the Downloads section (save this file on your workstation, click the Schema File Browse button, select Survey.sql from the save location, and then click Open).
- Database – DB2
Figure 7. Add and configure a database component
- Reference from the enterprise application to the database:
- Select the Enterprise Application component, and drag the dot that appears on the right side of this component to the Database component, thereby creating a one-way arrow.
- Select the newly created link, and set the JNDI Name of Data Source field to
Figure 8. Add and configure the Enterprise Application > Database link
- Click in an empty area of the diagram, and set the Name field to
Survey from RAD.
- Click Save in the upper-left corner to save your application pattern.
Your application pattern should now look similar to Figure 9.
Figure 9. Completed application pattern
- Close the Virtual Application Builder.
Acquire the cloud application and associate a sample project
Next, you must acquire the virtual application pattern that you just created on Workload Deployer as a cloud application in Rational Application Developer. After you do this, you can associate the deployable sample EAR project with it so that you can deploy the full application to Workload Deployer from Rational Application Developer.
- In Rational Application Developer, go to the Servers view, right-click on the Workload Deployer configuration, and select Acquire Cloud Applications.
The Acquire Cloud Application wizard will launch with a default query to find all applications already entered.
- Click Perform query to run this query.
- From the list of cloud applications, select Survey from RAD, which you created in the previous step, and click Next.
Figure 10. Acquiring an application
Now you must choose a project to house the cloud application.
- Select the CloudApplication project that you created at the start of this example, keep the default file name of appmodel.json, and click Next.
- In the Associations list, click on the Enterprise Application component entry in the table, and then click the ellipses (…) button.
- Select SurveyEAR in the pop-up window that follows, and click OK.
Figure 11. Associating a sample EAR with the acquired cloud application
- Click Finish to complete acquiring the application.
In the Enterprise Explorer view, you should now have an appmodel.json file within the applicationModels folder of the CloudApplication project. In the Servers view, under the Workload Deployer configuration, you should see appmodel [CloudApplication] already added.
Publish, start, and run the application
All that remains to do is to deploy and run the application. Because you added an association in the previous section, you must first publish the application from Rational Application Developer to update the virtual application pattern on the Workload Deployer, and then start the application to deploy it to the cloud.
In the Servers view under the Workload Deployer configuration, you should see appmodel [CloudApplication] already added.
- Right-click on Workload Deployer, and select Publish to update the pattern on the Workload Deployer appliance.
- When publication is finished (server status will change from [Connected, Republish] to [Connected, Synchronized]), right-click appmodel [CloudApplication] and click Start.
Figure 12. Starting the application
Deployment might take several minutes. After the application is deployed and started (shows a status of [Started, Synchronized]), you can run the application. To do this, you must determine the endpoint URL by using the dashboard.
- Launch the Workload Deployer dashboard (right-click on the Workload Deployer configuration in the Servers view, and select Launch Dashboard).
- A browser window will launch and take you to the dashboard.
If you previously logged out, you will be taken to a login screen, instead, where you need to enter your Workload Deployer user name and password and click Login.
- From the toolbar at the top of the dashboard, select the triangle icon (downward arrow) next to Instances and then select Virtual Applications from the drop-down menu.
Figure 13. Selecting Instances > Virtual Application from toolbar
- Select Survey from RAD.
- Click Endpoint under WAS in the Role Status column.
- Click the URL in the Endpoint Information pop-up window to launch the application.
Figure 14. Running the application through the endpoint URL
- The application should launch and show the screen in Figure 15.
Figure 15. Application logon screen
- Enter the user ID,
clouduser1, and password,
password, and click Logon.
- From the list of surveys that follows, you can enter responses to a survey by selecting the corresponding link.
Figure 16. List of surveys
Work with databases in Rational Application Developer
Deploying a cloud application containing a database component results in the provisioning of a database instance. In this example, the Survey.sql file contains the database definition that is associated with the database component for the Survey virtual application pattern. During the provisioning process, this database definition is executed, resulting in the creation of the specified tables and columns. During the development of cloud applications, you might need to view the contents of the actual provisioned database to validate the business logic or to manipulate the database contents.
Rational Application Developer includes database tools that you can use to operate on the provisioned database. Just as the endpoint for the enterprise application is exposed on the provisioned server that contains WebSphere Application Server, the database endpoint is also exposed for the corresponding database server.
In the Workload Deployer dashboard
For the running database VM (virtual machine), select and copy the endpoint URL:
- From the Workload Deployer dashboard toolbar, select the triangle icon (downward arrow) next to Instances, and then select Virtual Applications.
- On the screen that follows, select Survey from RAD.
- Under DB2 in the Role Status column, click Endpoint (see Figure 17).
- Select the Appuser URL in the Endpoint Information pop-up view: Copy the entire URL, starting at jdbc:db2. This URL contains all of the information to access the database.
Figure 17. Locating the database endpoint
In Rational Application Developer
Now, enable and view the Rational Application Developer database tools:
- Switch to Database Development perspective in Rational Application Developer.
- In the Data Source Explorer view, create a new database connection.
- In the connection parameter, select DB2 for Linux, UNIX, and Windows.
- The default driver is IBM Data Server Driver for JDBC and SQL (JDBC4.0)
Keep this default driver. It is provided by Rational Application Developer.
- Dissect the endpoint JDBC URL that you copied earlier, and enter corresponding values into the database connection wizard.
Figure 18. Translating the endpoint to locating the database endpoint
The resulting connection information should appear as shown in the Connection Parameter view (see Figure 19).
Figure 19. Database Connection Parameters dialog window
You can use the data source explorer view (see Figure 20) to see the active database connection, specific tables, and other database attributes.
Figure 20. Data source explorer view
You can also view the contents for a table, as well as run any supported SQL statements from within the tools. These features are available from the Database Development perspective. For more assistance with the database features, see the "Developing data access applications" section in the Rational Application Developer information center (see the Resources section here for a link).
The authors would like to thank Chris Brealey and Robert Taniwa for their reviews and feedback. Also, thanks to Ken McClamroch, who was the original designer and developer of the Survey application.
|Survey application to import and deploy||SurveyEJBEAR.zip||97KB|
|Database definition file||Survey.zip||2KB|
- See the introduction to IBM Workload Deployer for more information about how it can help you extend Smart SOA middleware and services into a private cloud. You can also watch overview demos, free (requires registration).
- Find out more about Rational Application Developer:
- See the "Developing data access applications" section in the Rational Application Developer information center.
- Browse the Rational Application Developer for WebSphere Software page on developerWorks for links to technical articles and many related resources.
- Visit the Rational software area on developerWorks for technical resources and best practices for Rational Software Delivery Platform products.
- Stay current with developerWorks technical events and webcasts focused on a variety of IBM products and IT industry topics.
- Attend a free developerWorks Live! briefing to get up-to-speed quickly on IBM products and tools, as well as IT industry trends.
- Watch developerWorks on-demand demos, ranging from product installation and setup demos for beginners to advanced functionality for experienced developers.
- Improve your skills. Check the Rational training and certification catalog, which includes many types of courses on a wide range of topics. You can take some of them anywhere, any time, and many of the "Getting Started" ones are free.
Get products and technologies
- Try Rational Application Developer for WebSphere Software, free.
- Evaluate IBM software in the way that suits you best: Download it for a trial, try it online, use it in a cloud environment, or spend a few hours in the SOA Sandbox learning how to implement service-oriented architecture efficiently.
- Check Rational Application Developer wiki to keep up with news and to contribute.
- Join the Development Tools forum to ask questions and participate in discussions.
- Rate or review Rational software. It’s quick and easy.
- Share your knowledge and help others who use Rational software by writing a developerWorks article. Find out what makes a good developerWorks article and how to proceed.
- Follow Rational software on Facebook, Twitter (@ibmrational), and YouTube, and add your comments and requests.
- Ask and answer questions and increase your expertise when you get involved in the Rational forums, cafés, and wikis.