Build a Java Data Objects application by using Rational Software Architect 8.0 and the Google App Engine SDK

Learn how you can use IBM® Rational® Software Architect to create a Java Data Object (JDO) enterprise application, leveraging the Google App Engine SDK. This article shows you how to do that by building an application with a design that is focused on business logic, not a pre-existing data store.


This article focuses on constructing a lightweight Java Enterprise Edition (JEE) application by leveraging the Java Data Objects (JDO) persistence approach. The Google App Engine SDK and corresponding runtime implementation provide an excellent JDO implementation that you will use to help in designing a sample application.

Before you start

  • Save the AcmeMembersAppWeb.jar file to a location of your choice on your file system.
  • To develop this application quickly, we used IBM® Rational® Software Architect for WebSphere®, Version 8.0. Alternatively, you can also complete the steps in this article by using these options:
    • The Rational Application Developer 8.0 toolset.
    • Any Eclipse development environment based on the Helios release (v3.6) with the appropriate Java and web development features included and a compatible JDK 1.6. You can download the free Helios release of the Eclipse IDE for Java EE Developers package from the Eclipse website.

If you are using the Rational Software Architect v8.0 or the IBM® Rational® Application Developer v8.0 environment, or another option, you will need to install a few additional items before you get started. Begin by installing the Google App Engine SDK, Version 1.3.8, and the Google Plug-in for Eclipse 3.6, Version 1.4, by following these steps:

  1. Start your Rational Software Architect software, using a workspace location of your choice. Start > IBM Software Delivery Platform > IBM Software Architect for WebSphere Software 8.0.
  2. When prompted to enter a workspace location, you can select the default location provided or enter another convenient location.
  3. If the Welcome window appears, close it.
  4. Follow the steps to install the Google App Engine SDK and Google Plug-in using the instructions found here: Note:
    You do not need to install the Google Web Toolkit package.

After you install the Google App Engine SDK and Google Plug-in and restart the Rational Software Architect IDE, you will notice that the buttons, shown in Figure 1, are now on your toolbar. Circled in Figure 1 is the New Web Application Project button, which you will use later.

Figure 1. The Google Plug-in for Eclipse toolbar icons
4 icons added to the Eclipse toolbar

In addition to following those instructions, we run our application using the Mozilla Firefox web browser, Version 3.6. When we run our completed application, the browser prompts us to install the Google Web Toolkit Developer Plug-in for Firefox. At the time of writing, the version installed for this add-on was 1.0.7511.

Why Java Data Objects

For many who want to design and construct applications focused on business logic, maintainability, and portability, Java Data Objects (or just JDO for short) are quickly gaining popularity, along with several other options that leverage a growing NoSQL movement.

Although the Java Persistence Architecture (JPA) also strives to accomplish many of these objectives, for some software architects and developers, the need to map Plain Old Java Objects (POJOs) to relational tables is intrusive to the application. The reason is that this mapping exposes and couples the application too closely to the persistent data store's schema. Moreover, the need to map POJOs to tables leads to what some describe as the "persistent impedance mismatch" problem, where the mapping itself influences the application's overall implementation to a higher degree than is desirable.

JDO does not require the application to provide any explicit mappings. Instead, it requires the developer only to denote the attributes to be persisted and to identify the attribute to represent the object's unique identifier (or primary key).

The Acme membership system sample application

Figure 2. The Acme Membership domain model
Diagram of the domain model

Larger view of Figure 2.

To receive Acme Company's services and benefits, their clients must become members. They can choose from Single, Student, or Family memberships. Family memberships provide Acme's services to couples and any children that they have who are under the age of 18. To remain members in "good standing," clients must renew their memberships annually.

All correspondence between Acme Co. and its members occurs solely through the primary member. Acme collects the address and other contact information for the primary member for all memberships for this purpose.

The Acme domain model in Figure 2 illustrates the structure and relationships between of our entities. No part of this model gave any consideration either to an existing or to a to-be developed underlying persistent store.

Creating the Acme membership application project

To create an Acme membership application project, follow the steps outlined below.

  1. Start Rational Software Architect v8.0 using a workspace location of your choice. Start > IBM Software Delivery Platform > IBM Software Architect for WebSphere Software 8.0.
  2. From the menu bar, select File > New > Web Application Project or, alternatively, click the toolbar button labeled New Web Application Project.
  3. In the Create a Web Application Project wizard, enter these values:
    1. AcmeMembersAppWeb for Project name.
    2. org.acme.membership.web for Package.
  4. Then unselect the check box for "Use Google Web Toolkit."
  5. Finally, click Finish.

See Figure 3 for additional guidance on how to complete this dialog window.

Figure 3. The New Web Application Project wizard
Create a Web Application window.

You will now import the initial part of the Acme membership application into your newly created project.

First, we will focus on the steps required to enhance a standard Java class (POJO) to become capable of JDO persistence.

  1. Import the initial web project that you will build upon.
    1. From the menu bar, select File > Import > General > Archive File and then click Next.
    2. Click the Browse button and navigate to the location where you saved the file AcmeMembersAppWeb.jar and select it for import.
    3. Ensure the "Into folder" field is set to AcmeMembersAppWeb by clicking the Browse button, and then navigating to and selecting the project that you previously created.
    4. Check the box labeled Overwrite existing resources without warning.
    5. Click Finish. There is no need to proceed to the other pages in the Import wizard.

See Figure 4 for additional guidance on how to complete this wizard.

Figure 4. Importing the beginnings of the Acme membership application
Import screen, Archive File view

After you have successfully imported the files, you will have a project layout, as Figure 5 shows. There will be three packages in your web project:

  1. org.acme.membership.domain, which holds the JDO enhanced business domain classes
  2. org.acme.membership.jdo, which holds a singleton JDO persistent manager factory used to retrieve JDO persistent managers
  3. org.acme.membership.web, which holds the servlet and other artifacts related to the web interface

Note: You will see one warning in the Problems view that you can safely ignore.

Figure 5. The project layout for the AcmeMembersAppWeb project
Package Explorer tab view

Enhancing a class with JDO persistence capabilities

The current version of the Google tooling for Eclipse does not offer much in the way of wizards to automatically transform a standard Java class into a JDO compliant class. Fortunately, there are only a few steps required to do this, and most of them involve using short annotations.

  1. Open which can be found under AcmeMemberAppWeb > src > org.acme.membership.domain.
  2. Add the classes shown in Figure 6 to your import list.
Figure 6. Classes to add to the import list for a JDO-enhanced class
5 classes listed

Once you have created your Google Web Project (AcmeMembersAppWeb), the addition of appropriate libraries and updates to the project classpath will happen automatically. The Rational Software Architect solution's Eclipse build environment will find the classes added to the import list (as shown in Figure 6).

  1. At the top of the class definition, add the annotation @PersistenceCapable as shown in Figure 7. This annotation instructs Google App Engine's persistence services to manage instances of this class.
Figure 7. Declaring a class to be persistence capable
@PersistenceCapable included in the code
  1. Our class will need to define an identifier to distinguish one instance of our AcmeMembership class from another. The Google JDO implementation has a particular Key class/type that we will use. We will include this Key as an attribute of AcmeMembership, mark it as a Primary Key, and specify the strategy the Google App Engine runtime will use to populate it automatically with unique values.
    1. Add an attribute called id of type Key (see the import list for the fully qualified class name).
    2. On top of the declaration of id, add the annotation @PrimaryKey.
    3. Under the @PrimaryKey annotation, add another annotation as follows: @Persistent(valueStrategy = IdGenerator.IDENTITY)
    4. Add a getter and setter for the id attribute. For this step you can use the Quick Fix feature or you can highlight the id attribute, right click, and select Source->Generate Getters and Setters
Figure 8. Denoting an attribute as the primary key and its value population strategy
Two annotations in code highlighted
  1. Declare our intention to persist the remaining attributes of interest using the annotation @Persistent. The only attribute that we are not interested in persisting is INITIAL_FAMILY_SIZE.
    1. Add the annotation @Persistent on top of the declaration for these items: acmeMembers, type, creationDate, and lastRenewed.

With nothing more than the @Persistent annotation, we were able to make a complex and diverse number of attribute types persistent, including a List (acmeMember), an enum (type), and a Date (creationDate).

The PersistenceManagerFactory and PersistentManager

To help the application generate a PersistenceManager, a JDO Application requires a class containing a singleton attribute of type PersistenceManagerFactory. A PersistentManager is required to obtain a Transaction. A JDO Transaction instance is the vehicle for carrying out a unit of work, according to the conventional definition of a transaction, against a persistence storage system (or database).

MembersAppDomainPMF (found under AcmeMemberAppWeb > src > org.acme.membership.jdo) is the class where we have placed our singleton PersistenceManagerFactory attribute.

Figure 9, which follows, shows a snippet of source code, (found under the package org.acme.membership.web) that demonstrates two things:

  1. How to obtain and use a transaction from a PersistenceManager.
  2. How to persist a (complex) object by invoking the makePersistent() method.
Figure 9. Source code for obtaining and running a JDO transaction
Code snippet (screen capture)

Run the application

Now you can run your sample Acme Membership application, which will add a single membership to the Acme membership system.

We ran our application using a locally hosted Google App Engine Web Application Server. You can also deploy, host, and run this application in the Google cloud.

  1. In the Package Explorer view, right-click the web application project, AcmeMembersAppWeb, and select Run As > Web Application.
Figure 10. Starting the Google App Engine test environment
Selections on 2 drop-down menus
  1. After the Google App Engine has successfully started, the console view will show an informational message indicating that the server is running (see Figure 11).
Figure 11. Console message indicating the Google App Engine test server is ready
Date, time, message, location of server
  1. Launch a browser, and enter the following URL for the destination address:
  2. Click the link for AcmeMembersAppWeb, and it should return the output of a membership that we added to our system.


For this article, we used Rational Software Architect for WebSphere v8.0 to help rapidly design and enhance Java classes to make them "JDO-capable" and executable, using the Google App Engine as our JDO runtime implementation

Neither the relationships between our classes, nor the application logic took into consideration the characteristics or structure of an underlying persistence storage. We did not map any attributes to any relational or nonrelational database tables. Even so, by building an application with a design focused on business logic, not a pre-existing data store, we showed that how Rational Software Architect can help your team craft JDO-capable applications.


The author thanks Mike Reid for his thoughtful and thorough review of this article.


Initial Web Application for developingAcmeMembersAppWeb.zip4KB



Get products and technologies



developerWorks: Sign in

Required fields are indicated with an asterisk (*).

Need an IBM ID?
Forgot your IBM ID?

Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.


All information submitted is secure.

Dig deeper into Rational software on developerWorks

ArticleTitle=Build a Java Data Objects application by using Rational Software Architect 8.0 and the Google App Engine SDK