The J2EE RI comes with a verifier utility that you can use to validate the contents of an EAR file. The verifier can be run from the command line or it can be invoked from the Tools, Verify J2EE Compliance... menu option from within deploytool.
You are advised to run verifier on all new EAR files or when changes have been made to any of the files composing an EJB. To illustrate the use of the verifier, Figure 4.10 shows the errors produced by a simple mistake in coding the AgencyBean.java class; in this case the ejbCreate() method was mistakenly defined as create().
Running the verifier from within deploytool produces a list of failed tests or a brief "There were no failed tests" message. Selecting each failed test in turn will supply further information about the test. In Figure 4.10 the message indicates the following:
[agency.AgencyBean] does not properly declare at least one ejbCreate() method
A simple mistake can cause the failure of many tests, so do not be alarmed if you see a large number of test failures.
After you have written, packaged up your application, and verified the application contents, you are ready to deploy.
Deploying the Case Study Application
You can deploy the server-side components of the agency application using deploytool. To deploy the agency application, select the agency application item (indicated by a blue diamond under the Applications folder in the explorer area in the left-hand panel), and select the Tools, Deploy... menu. This will display the initial deployment screen shown in Figure 4.11.
You will need to provide the administrative username and password (admin and password if you installed the J2EE SDK as described on Day 2). You should also check the Return Client Jar box on the dialogue to ensure your Application Client Jar file is downloaded from the J2EE server. Accept the default location for the client JAR file (this will be the same directory as the EAR file).
Click on OK to proceed with deploying your application and then click Close on the popup window when the deployment completes.
This is the point at which things might go wrong. If you are using the software from the Web site, you should have no trouble, but if you are developing your own example then you might come across problems at this stage. The "Troubleshooting Deployment" section, later on, discusses problems that might occur at deployment. If something does go wrong, study the information in the deployment progress window and also look at the J2EE console window for additional, more detailed information.
Running the Application Client
After you have successfully deployed the server-side components of the application under the J2EE RI, you can run the simple application client to test the application.
To run an application client you must have obtained the client-side JAR file from the deployed application. You did this when you deployed the application by checking the Return Client Jar... box on the deployment popup window. You can also obtain the client JAR file using either deploytool, the Web-based Admin Console, or the command line asadmin utility as described in the following section "Managing J2EE RI Applications."
The client JAR file contains all the client and EJB class files as well as the RMI stub files required to run the application client.
You run a J2EE RI application client using the appclient command (from the J2EE SDK bin directory). The appclient requires the name of the client JAR as its single –client parameter. Assuming you have followed the deployment process described in the previous section, your returned client JAR file will be in the Day02/exercise/ j2ee-ri directory and called agencyClient.jar.
You can run your deployed client as follows (your command entry is shown in bold):
appclient -client j2ee-ri/agencyClient.jar
The client JAR file is always named after the application by appending Client.jar to the name of the application.
Congratulations, you have just deployed and run your first J2EE application. If the client fails to run, then look at the errors on the console window or in the domains/domain1/logs/server.log file in the J2EE SDK home directory for more information.
If you want to examine the simple Web Application you deployed with the EJB, then browse to the URL http://localhost:8000/webagency. You will look at Web Applications in detail on Days 12, 13, and 14.
blog comments powered by Disqus