Configuring J2EE RI Client Applications with deploytool

All J2EE RI clients must be added as client applications to an EAR file and deployed in the same manner as EJBs. The example case study simply adds the client applications to the same EAR file as the Session beans.

The Agency case study client application is a Swing GUI client with dialog tabs for customers advertising jobs, applicants registering for jobs, administrators configuring locations and skills and database table debugging. The supplied agency.ear example for the Day 5 exercises already includes a partially configured Agency client called AllClients.

When creating a client application you will need to include all of the classes for the client together with the home and remote interface classes for every EJB used by the client. Continuing the exercise of updating this application to include the Agency EJB you need to add the following files to the AllClients component:

agency.Agency

agency.AgencyHome

Add these files using deploytool by selecting the AllClients component in the left pane and the JAR File tab in the right pane. Click on Edit to highlight the two interface classes listed above, and then click on Add to include them in the Agency EJB. Close down the edit dialog box when you have made your additions. You should now have the list of EJB classes shown in Figure 5.15 in your client application.

Figure 5.15. Application Client EJB Interface Classes.


Your final step to complete the addition of the Agency Session bean to the case study is to add the EJB reference for the Agency Session bean to the AllClients component. Select the AllClients component in the left pane and the EJB Refs tab in the right pane. Click on the Add button and in the popup window supply the following information (as shown in Figure 5.16):

  • Coded Name— ejb/Agency

  • EJB Type— Session

  • Interfaces— Remote

  • Home Interface— agency.AgencyHome

  • Local/Remote Interface— agency.Agency

Figure 5.16. Adding an EJB Reference.


You will have select lists for all of the values except the coded name. If you do not see the Agency EJB classes in the popup lists you did not include the classes in the client application JAR file as previously described.

By doing this you have added the following elements to the AllClients entry in the application-client.xml deployment descriptor (shown in bold):

<?xml version='1.0' encoding='UTF-8'?>
<application-client
      version=" 1.4"
      xmlns=" http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation=" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee
/application-client_1_4.xsd"
      >
   <display-name> AllClients</display-name>
   <ejb-ref>
						<ejb-ref-name>ejb/Agency</ejb-ref-name>
						<ejb-ref-type>Session</ejb-ref-type>
						<home>agency.AgencyHome</home>
						<remote>agency.Agency</remote>
						</ejb-ref>
...
</application-client>

Click on OK to add the new EJB reference. You must now provide the platform specific JNDI mapping for the Agency EJB reference. Do this by selecting the Agency EJB row you have just created in the EJB Refs pane, and in the Sun-specific Settings at the bottom of the page select the JNDI Name option and enter ejb/Agency. This is shown in Figure 5.17.

Figure 5.17. Defining an EJB Reference JNDI Name.


You have now added the following elements to the AllClients entry in the sun-application-client.xml deployment descriptor (shown in bold):

<sun-application-client>
...
   <ejb-ref>
						<ejb-ref-name>ejb/Agency</ejb-ref-name>
						<jndi-name>ejb/Agency</jndi-name>
						</ejb-ref> 
...
</sun-application-client>

You have now added the Agency Session bean and defined an EJB reference to it in the AllClients application. Save your changes and use the Tools, Verify J2EE Compliance… menu option to run verifier to verify the whole application including your newly added EJB reference.

Save your changes and then use the Tools, Verify J2EE Compliance… menu option to start up the GUI verifier.

NOTE

As previously described the Nov 2003 release of the J2EE RI deploytool incorrectly reports errors for the Agency application. The authors suggest you use the command line verifier on the EAR file you have just updated using the command:

asant verify-j2ee-ri


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.72.133