![]() |
Packaging: Sample "A" Sample Application |
Packaging: Sample "A" Sample Application
This sample application document contains the following sections:
Overview
Compiling and Assembling the Application
Deploying the Sample Application
Overview
Figure 1 illustrates a very simple packaging: a single EAR file (pkgingAApp.ear) contains one EJB JAR file (pkgingAAppEjb.jar) and one WAR file (pkgingAApp.war).
Figure 1    Packaging Sample "A" The essence of this packaging sample is to illustrate the following concepts:
WAR to EJB JAR communication: Servlets make calls to the EJBs
For example, the SimpleInterest EJB is named "SunONE.pkgingA.pkgingAEJB.SimpleInterest". This naming scheme allows for unique naming of EJBs across all applications.Naming scheme for EJBs: The EJBs are named in the format: <companyname>.<earname>.<modulename>.<EJBName>.
You may refer to Running the Sample Application for instructions on running the sample. To better understand sample application source code, you can generate javadocs using asant javadocs and access them at <install_root>/samples/packaging/pkgingA/javadocs/index.html.
Compiling and Assembling the Application
Compile and Assemble Packaging Sample A
You are now ready to use this ear file for deployment.
Deploy the application.
- Execute asant under <s1as_install_dir>/samples/packaging/pkgingA/src/.
- The default target core will be executed to rebuild the WAR and EAR files.
Clean the web application project area. For example:
- Once you have re-created the sample application from scratch, proceed to Deploying the Sample Application.
Deploying the Sample Application
Select one of the following methods of deploying the application:
Command Line Interface (CLI)-based Deployment describes how to manually register the sample application using a Command Line Interface (CLI). This is the fastest means of deploying the application to the application server.
Web Interface (GUI)-based Deployment describes how to use the Sun ONE Deployment Tool to import and deploy the sample application. Alternatively, you can also assemble the application from scratch and deploy it using the Deployment Tool.
Command Line Interface (CLI)-based Deployment
Since a complete EAR file is supplied, the fastest means of setting up the application is to use the command line utilities as described in this section. If you would like to experience deploying through a GUI tool, then follow instructions in Web Interface (GUI)-based Deployment.The pre-built pkgingAApp.ear file is a Enterprise Archive file that contains the Web Archive (WAR) file of the application. Within the WAR file resides the XML deployment descriptor files, application class files, JSPs and other content required by the application.
Deploying the pre-built pkgingAApp.ear file is simple. Deploy either Using asant script or Using asadmin command.
Go to the src directory of the sample. For example: <s1as_install_dir>/samples/packaging/pkgingA/src.
Execute the following command:
Go to the root of the sample directory. For example:
The deployment process involves the following operations:Execute asadmin to deploy the module to the local application server instance. For example:
Authenticates against the local application server's administrative server.
If you would like to verify the registration of the application, proceed to Verifying Registration. Otherwise, you are now ready to exercise the application by Running the Sample Application.The EAR file is transferred to the administrative server.
The administrative server begins the registration process:
Verifying Registration
As an optional step, you can use the Sun ONE Application Server Administration Tool to verify that the application has been registered. If you do not want to verify that the application has been registered, proceed directly to Running the Sample Application.To verify the registration of the application, do one of the following:
Execute asadmin to look at applications deployed with a server instance. For example:
Navigate the Admin tool GUI to App Server Instances>server1>Applications>Enterprise Apps.
- asadmin list-components -u <username> -w <password> -H <host> -p <admin-port> <server instance name>
Web Interface (GUI)-based Deployment
Since a pre-built Enterprise Archive (EAR) file for the sample application is included with the application server, you can use the Admin Tool to quickly read in the .ear file and deploy it to the application server.
Open the pre-existing sample EAR file.
If the deployment goes through fine, you will see the original pane with pkgingAApp application as deployed.Start the admin server if it is not already started:
Windows:
Open the EAR file:
Enter your username and password to access the admin server
Click on App Server Instances>server1>Applications>Enterprise Apps
In the right hand pane, click on Deploy to deploy an application. Choose the file (from disk) to be deployed pkgingAApp.ear and Click OK.
You will be asked for the application name. Enter pkgingAApp and Click OK.
Running the Sample Application
To run the application, go to the following URL: http://<hostname>:<port>/pkgingATraverse the JSP and Servlet links to execute each simple web sample application.
After javadocs are generated, you can access them at To understand sample application source code better, you can refer to the related javadocs. To generate javadocs run the following command from the src directory
<install_dir>/samples/packaging/pkgingA/javadocs/index.html
Although the war, ear, context-root and servlet alias names in this sample are all pkgingAApp, it is not necessary that it be so. The application will work as expected if the names of each of these attributes is unique. Rebuild the app after changing the context-root (in application.xml), the servlet alias (in web.xml) and the war and ear names, redeploy and test the sample to confirm this.
Some Known Issues:If you encounter problems when running the application, review the log files at <s1as-install-dir>/domains/domain1/<server-instance>/logs/server.log to learn what exactly went wrong.
- The sample can not be deployed from the application server administration GUI, if Run verifier option is selected. Solution is, try deploying the application without Run verifier, or deploy using asant.
- The sample can not be deployed using asadmin with option --verify=true. Solution is, try deploying the application without the option --verify=true, or deploy using asant.
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated August 13, 2002