Creating a web page, web service, or EJB from a J2C Java bean

The final process in creating a Java application that accesses an IMS transaction is to wrap the J2C Java bean in a web page, web service, or EJB so that it can run on a J2EE application server such as WebSphere Application Server.

This example illustrates how to wrap the J2C Java bean using a JSP dynamic web application. To create a JSP dynamic web application from a J2C Java bean, complete the following steps:
  1. To start the J2C dynamic wizard, from the menu bar, select File > New > Other > J2C.
  2. With the J2C folder expanded, select Web Page, Web Service, or EJB from J2C Java Bean.
  3. Click Next.
  4. In the J2EE Resource from J2C Java Bean wizard, complete the following steps:
    1. On the J2C Java bean selection page, next to the J2C bean implementation entry field, click Browse.
    2. In the Select entries field, prime the entry field with an asterisk (*) to view the available data types, select PBImpl.java from the Matching types list and click OK.
    3. The J2C bean implementation field should contain /PhoneBookJ2CBean/sample/ims/PBImpl.java.
  5. Click Next.
    Note: If you get the message, "Resource nnnnn, referenced by the J2C code, is not found on servers. Please make sure that resource nnnnn exists," it may be that the resource has not been saved to the master configuration of the server. If you do not get this error, continue to Step 6.

    Otherwise, to eliminate this error message, select Cancel, then perform the following steps to save your resource to the master configuration of the server:

    1. In the Servers view, ensure that the server is started.
    2. Right-click the server and select Run administrative console.
    3. Log in to the administrative console.
    4. In the left pane, expand Resources and select Resource adapters.
    5. At this point a warning message may appear, "The master configuration has been updated. You currently have workspace conflicts with these modifications. To see these updates you must Save or discard your current workspace modifications." Save your modifications.
    6. If the problem persists, try stopping and starting the server.
  6. In the Deployment Information page, select JSP and then click Next.
  7. In the JSP Creation page, select Create a Faces JSP and add J2C Java bean as available page data.
  8. Next to Web project, click New, to create a new dynamic web project. The New Dynamic Web Project window opens.
  9. In the Name field, type PhoneBookWeb and click Finish.
  10. Select Yes to switch to the web perspective when requested to do so.
  11. In the JSP Creation page, leave the JSP Folder name blank.
  12. For the name of the Faces file, type PBookF.
    Note: The name of the EAR project defaults to PhoneBookWebEAR.
  13. Click Show Advanced and type a name for the Resource Reference. For example, myCFacRef. Note: It is strongly recommended that you provide a resource reference for your J2EE resource. Not only does this allow you to map your J2EE resource to different J2C connection factories when you install your EAR on other WebSphere Application Servers, but if you do not use a resource reference you may receive unpredictable results when running your application.
  14. Click Finish. The file, PBookF.jsp opens in the JSP editor.
  15. Ensure that the Design tab in the JSP editor is selected.
  16. Ensure that the Page Data view is open.
  17. In the Page Data view, complete the following steps:
    1. Expand java (sample.ims.PBImpl).
    2. Drag and drop the method runPB(sample.ims.data.INPUTMSG) onto the Design view of PBookF.jsp in the JSP editor. The runPB(sample.ims.dat.INPUTMSG) method entry in the Page Data view is identified with an M icon. If you have exposed properties of IMSInteractionSpec or IMSConnectionSpec, the signature of the runPB method will contain additional arguments.
    3. In the Configure Data Controls page of the Insert Java Bean wizard, select the fields that you wish to use to input data to the runPB method and optionally the exposed input properties of IMSInteractionSpec and IMSConnectionSpec. Then, click Next. You can change the order of the input fields by selecting a checked field and using the up and down arrows to the right of the Fields to display list to move the input field.
    4. Use the next page of the Insert Java Bean wizard to select the fields that you wish to see as output data from the output message of the runPB method, and optionally the exposed output properties of IMSInteractionSpec. Select the fields that you wish to see as output data from the runPB method and then click Finish.
    5. Close PBookF.jsp to save your changes.
You have now wrapped the J2C Java bean in a web page so that it can run on a J2EE application server.
Related tasks
Creating IMS Java data bindings
Creating a J2C Java bean
Exposing InteractionSpec and ConnectionSpec properties for input as data
Exposing InteractionSpec output properties as data
Using IMS data bindings in a CCI application
Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.