An easier way to connect components to SAP server functions: Part 2. Create a JavaServer Page for the connector and test the J2C bean

This is the second part of a two-part article. It demonstrates how to use Java EE connector tools in IBM® Rational® Application Developer 8.0 to generate a J2C bean in a Java EE application to communicate with a SAP server that is running at the back end of an enterprise information system.


Ellen L. Chen (, Software Developer, IBM

author photoEllen Chen is a software developer with the IBM Rational Java EE Connector Tools team in the IBM Toronto Lab. She has a bachelor’s degree in engineering.

16 August 2011


This article is continues Part 1, where you generated and tested a J2C (or JCA) bean for a SAP resource adapter outbound scenario, using the enhanced Java EE connector tools in Rational Application Developer Version 8.0. The J2C bean artifacts have been generated in the workspace and the workspace has been launched. Part 1 also tells you what you need to have installed to work through this hands-on example.

Be sure that you've read that article before proceeding with this one. You can find it easily by clicking "More in this series."

Create a simple JSP to expose the J2C bean functionality

After the "J2C Java bean selection" view is launched under the "Java EE Resource from J2C Bean" window, the path to the generated J2C bean that you generated in Part 1 is automatically entered in the "J2C bean implementation" field (see Figure 1). Now you need to create a simple JavaServer Page (JSP) to expose the functionality provided by the generated J2C bean.

  1. In that "J2C Java bean selection" window, click Next.
Figure 1. Select the J2C bean to generate deployment artifacts
J2C Java bean selection view
  1. On the Deployment Information page (Figure 2), there are four deployment options: EJB, Faces Web Page, Simple JSP and Web Service. The default deployment method is Simple JSP.
  2. Check the box labeled Configure Resource Adapter Deployment so you can configure the way that the resource adapter deployment will show, in step 5.
  3. Click Next.
Figure 2. Simple JSP selected by default
Deployment Information page, selections completed
  1. To generate a Simple JSP, you need to create a dynamic web project to hold it, so click the New button next to the web project to generate that project. For Target Runtime, use WebSphere Application Server V7.0.

The name of the web project will automatically show in the "Web project" name field.

  1. For the "JSP folder" name, enter sample (see Figure 3), and click Next.
Figure 3. Generate the simple JSP
Specify Web project and JSP folder which holds the simple JSP
  1. When the Resource Adapter Deployment page appears, click Finish to generate the deployment artifacts.

If you do not select the "Configure Resource Adapter Deployment" check box in step 2, this page won't show.

The default SAP resource adapter deployment is "Deploy as Stand Alone," which means that the resource adapter will be installed on WebSphere Application Server. For this example, it will be installed on Version 7.0. After it is installed on that server, the applications that need the SAP resource adapter to connect SAP server can share the same resource adapter.

However, if you select "Deploy within EAR," the resource adapter will be packaged within the EAR file and will not be visible or used by other applications.

Figure 4. Select the default resource adapter deployment option
Two options for Resource Adapter Deployment: Deploy as Stand Alone and Deploy within EAR
  1. Inspect the content of the Java project and the web project. Figure 5 shows the structure of the artifacts generated both for the Java project, SAPBAPISample, and the web project TestWeb.

The J2C bean is generated in the Java project with schema files, and simple JSPs are generated in the web project.

Figure 5. Artifacts generated for both the web and Java projects
Directory of SAPBAPISample and TestWeb artifacts

Test the simple JSP on WebSphere Application Server

  1. First, you must deploy an EAR file that contains your web project to the WebSphere Application Server, Version 7.0, as shown in the Add and Remove window in Figure 6.
Figure 6. Add the EAR file to the WebSphere server
Add and remove resources configured on the server

To deploy the EAR file to the WebSphere, you need to open the Server view, right-click the WebSphere 7.0 server instance, and select Add and Remove.

  1. Now, right-click TestClient.jsp, and then select Run As > Run on Server (see Figure 7).
  2. Run TestClient.jsp on the WebSphere Application Server.
Figure 7. Test the createSapBapiDemoWrapper method
Selections described are highlighted on menus
  1. In the left pane of the Web Services Test Client tab (TestClient.jsp file), under Methods, click createSapBapiDemoWrapper in. Input data is shown in the Inputs.jsp file which is shown in Figure 8.
Figure 8. Test the "createSapBapiDemoWrapper" method
Display all input fields to create a new customer record
  1. Enter this input data in the Inputs.jsp file:
    1. Under sapPiPersonaldata, enter those values:
      • city: Burlingame
      • lastName: Johnson
      • firstName: Tom
      • countryKey: US
      • currencyKey: USD
      • cityPostalCode: 94010
      • dateOfBirth: May 03, 1965
      • languageKey: EN
      • regionStateProvinceCounty: CA
    2. Under sapPiCopyreference, enter the following values:
      • distributionChannel: 01
      • division: 01
      • salesOrganization: 0001
      • referenceCustomer: 01
  2. Then click Invoke from Result.jsp to create a new customer number.
Figure 9. The Result.jsp display
Shows the newly created customer

As Figure 10 shows, similar log messages are displayed from the WebSphere Application Server console view.

Figure 10. WebSphere Application server console view log


This article showed how easy a J2C bean can be created with the J2C tools provided in Rational Application Developer V8.0. With just a few steps, you can build an application that can access the functions of the SAP backend system. That functionality can be quickly exposed to other applications and business processes through the generated web page.



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

Zone=Rational, DevOps
ArticleTitle=An easier way to connect components to SAP server functions: Part 2. Create a JavaServer Page for the connector and test the J2C bean