![]() |
Packaging: Sample "C" Sample Application |
Packaging: Sample "C" Sample Application
This sample application document contains the following sections:
Overview
Compiling and Assembling the Application
Deploying the Sample Application
Overview
Figure 1 illustrates how a remote client can access an EJB deployed as a stand-alone module on a Sun Java (tm) System application server. The EJB module contains a single EJB named ModuleEJB and accesses few utility classes.
Figure 1    Packaging Sample "C" The essence of this packaging sample is to illustrate the following concepts:
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/pkgingC/javadocs/index.html.
Compiling and Assembling the Application
Compile and Assemble Packaging Sample C
You are now ready to use this ear file for deployment.
Deploy the application.
- Execute asant under <sjsas_install_dir>/samples/packaging/pkgingC/src/.
- The default target core will be executed to rebuild the EJB JAR and client JAR 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 Java (tm) System 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 the essence of this sample is to illustrate a module based registration, we'll focus only on the EJB JAR module i.e. pkgingCAppEjb.jar. Deploying this file is very similar to deploying an ear file, except that the deployer must be told that the type is an ejb. Deploy either Using asant script or Using asadmin command.
Go to the src directory of the sample. For example: <sjsas_install_dir>/samples/packaging/pkgingC/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, go to:
Execute the following:
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 JAR 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 Java (tm) System 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>
- You will see the pkgingCAppEJB as one of the listed modules.
Web Interface (GUI)-based Deployment
Open the EJB JAR file i.e. pkgingCAppEjb.jar.
Start the admin server if it is not already started:
Windows:
Open the JAR file:
Enter your username and password to access the admin server
Click on App Server Instances > server1> Applications > EJB Modules
In the right hand pane, click on Deploy to deploy an application. Choose the file (from disk) to be deployed pkgingCAppEjb.jar and Click OK.
Running the Sample Application
A pre-requisite for running the remote client is that, the EJB module must first be deployed in an application server. See the Deploying the Sample Application section for details. Also, make sure that the PATH and CLASSPATH variables are set for the remote host and they refer to appropriate JDK. Running the remote client can be achieved through these following simple steps:
Setup a staging directory for the client.
The application should generate the following messages (these are the values returned from the ModuleLibraryEJB):Copy the necessary JAR files to the remote host.
- Copy the following files from the server host and keep them in the staging directory. The files needed to run this client are:
pkgingCAppClient.jar
Set the CLASSPATH for running the client.
pkgingCAppEjbClient.jar
- This archive contains the client class file(s) and can be found at <sjsas_install_dir>/samples/packaging/pkgingC/assemble/client
appserv-ext.jar
- This contains the stubs, remote and home interface for the bean to be invoked remotely. Deployer generates this file while deploying the EJB module and copies it to this location. This can be found at <sjsas_install_dir>/samples/packaging/pkgingC/assemble/client
Execute the Java Application Client.
Doing a JNDI lookup on ejb/SunONE.pkging.pkgingCEJB.ModuleLibrary
2 raised to the power of 3 is 8.0
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
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated August 13, 2002