Skip Headers
Oracle® Containers for J2EE Deployment Guide
10g (10.1.3.1.0)

Part Number B28951-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

3 Deploying Enterprise JavaBeans

The following topics discuss deployment or redeployment of Enterprise JavaBean modules into an application running in an OC4J instance.

Overview of EJB Deployment

The EJB deployment process is highly automated. When an application containing one or more EJB JAR files is deployed, OC4J executes as follows:

  1. OC4J generates a wrapper class for each of the home interfaces (EJBHome and EJBLocalHome implementations) and component interfaces (EJBObject and EJBLocalObject implementations) packaged within each EJB JAR file.

  2. OC4J invokes the Java compiler that it is configured to use to compile the generated EJB wrapper classes. The compiled classes are output to an archive named deployment-cache.jar in a new subdirectory with the same name as the deployed EJB JAR in ORACLE_HOME/j2ee/instance/app_name/application-deployments/.

    For example, suppose you deployed mystore.ear, which contains inventory-ejb.jar. The compiled wrapper classes will be generated in ORACLE_HOME/j2ee/instance/mystore/application-deployments/inventory-ejb/deployment-cache.jar.

  3. OC4J optionally generates client-side IIOP stubs for each home and component interface if configured to do so.

See "Example of a Deployed Application Directory Structure" for an example of the directory structure created for an application by OC4J.

Note that because of the amount of processing performed by OC4J and the Java compiler, deploying an EJB JAR file containing a large number (~100) of EJBs may significantly increase the amount of time required to deploy an application. See Chapter 4, "Deploying Large Applications" for guidelines on tuning OC4J and the Java compiler for large-application deployment.


Note:

If you are using the Application Server Control Console, EJB 3.0 entities deployed with session beans are not visible in the Application Server Control view of the EJB JAR module. After you deploy EJB 3.0 entities to OC4J, you cannot manage them through the Application Server Control Console. If you use Application Server Control to view your EJB module, the Entity Beans area will display "No entity beans found".

You can manage all other EJB 3.0 beans such as session beans. For example, if you deploy an EJB module that contains both EJB 3.0 entities and EJB 3.0 session beans, your session beans will be visible through Application Server Control.

For more information about managing EJBs, see the Oracle Containers for J2EE Enterprise JavaBeans Developer's Guide.


Generation of Client-Side IIOP Stubs

OC4J optionally generates client-side IIOP stubs for each home and component interface if configured to do so when you deploy with Application Server Control Console, admin_client.jar, or the OC4J Ant tasks.

Generating Stubs with Application Server Control

See "Deploying or Redeploying an Application" for instructions on deploying applications with Application Server Control Console.

  1. Before deploying the EJBs, configure OC4J to generate client-side IIOP stubs in the Application Server Control Console.

    1. Click the Administration tab for an OC4J instance.

    2. Under Properties, select EJB Compiler Settings.

    3. Under Compile Time Parameters, select Generate IIOP Client Stubs when Compiling EJBs .

  2. Next, enable stub generation at deployment time:

    1. In the third panel (Deployment Settings) of the deployment wizard, click Edit Deployment Plan.

    2. Set enableIIOP to true.

The application-level stubs generated for all EJB modules are output to an archive named _iiopClient.jar in the ORACLE_HOME/j2ee/instance/application-deployments/app_name directory.

In addition, stubs for each individual EJB module are generated in an archive with the same name in the ORACLE_HOME/j2ee/instance/application-deployments/app_name/ejbModuleName/ directory.

Generating Stubs with admin_client.jar

The -deploy command on the admin_client.jar command line provides two options for generating IIOP stubs: one for generating stubs on the server, the other for generating stubs on the server and copying the new stubs to another location.

  1. Before deploying the EJBs, set the -DGenerateIIOP system property, which configures OC4J to generate client-side IIOP stubs at startup.

    • In standalone OC4J, specify this system property on the OC4J command line:

      java -DGenerateIIOP=true -Dhttp.session.debug=true -jar oc4j.jar
      
      
    • In an OPMN-managed OC4J instance, set the property in opmn.xml:

      <ias-component id="default_group">
        <process-type id="home" module-id="OC4J" status="enabled">
          <module-data>
            <category id="start-parameters">
              <data id="java-options" value="-DGenerateIIOP=true
               -Dhttp.session.debug=true"/>
            </category>
            ...
          </module-data>
        </process-type>
      </ias-component>
      
      
  2. Next, deploy the application with the admin_client.jar -deploy command. See "Deploying an Archive" for details on using this command.

    • Include -enableIIOP to generate IIOP client stubs on the OC4J server.

      The application-level stubs generated for all EJB modules are output to an archive named _iiopClient.jar in the ORACLE_HOME/j2ee/instance/application-deployments/appName directory. In addition, stubs for each individual EJB module are generated in an archive with the same name in the ORACLE_HOME/j2ee/instance/application-deployments/appName/ejbModuleName/ directory.

    • Include -iiopClientJar path to generate stubs in the same locations specified above, as well as to the path specified with the switch.

    • Include -removeArchive to delete the deployment archive from the server's file system after deployment.

Generating Stubs with the OC4J Ant Tasks

The deploy Ant task also provides two options for generating IIOP stubs: one for generating stubs on the server, the other for generating stubs on the server and copying the new stubs to another location.

  1. Before deploying the EJBs, set the -DGenerateIIOP system property, which configures OC4J to generate client-side IIOP stubs at startup. See "Generating Stubs with admin_client.jar" above for details.

  2. Next, deploy the application with the deploy task. See "Deploying a J2EE Application (EAR)" for details on using this task.

    • Include enableIIOP to generate IIOP client stubs on the OC4J server.

      The application-level stubs generated for all EJB modules are output to an archive named _iiopClient.jar in the ORACLE_HOME/j2ee/instance/application-deployments/appName directory. In addition, stubs for each individual EJB module are generated in an archive with the same name in the ORACLE_HOME/j2ee/instance/application-deployments/appName/ejbModuleName directory.

    • Include iiopClientJarPath to generate stubs in the same locations specified above, as well as to the path specified with the switch.

Incremental Redeployment of Updated EJB Modules

OC4J supports incremental or partial redeployment of EJB modules that are part of a deployed application. This feature makes it possible to deploy only those beans within an EJB JAR that have changed, without requiring the entire module to be redeployed. Previously deployed beans that have not been changed will continue to be used.

This functionality represents a significant enhancement over previous releases of OC4J, which treated an EJB module as a single unit, requiring that the module first be undeployed, then redeployed with any updates.

A restart of OC4J is required only if changes are made to the EJB configuration data during the redeployment process. If no changes are made, a Òhot deploymentÓ can be performed without restarting OC4J.

The incremental redeployment operation will automatically stop the application containing the EJB or EJBs to be updated and then automatically restart the application when finished.


Note:

During redeployment, any client connections to the EJB being updated will be lost. It is strongly recommended that the application be stopped before redeploying the EJB. All existing requests will be allowed to complete, but no new requests will be allowed until the application is restarted.

For CMP or BMP entity beans, OC4J uses code generation to generate the server implementation of the EJB interfaces (wrappers). In this case, incrementally redeploying only changed beans is most likely to be more efficient than redeploying the entire application.

For session beans, message-driven beans, and EJB 3.0 JPA entities, OC4J uses byte code generation to generate wrappers. Because this approach reduces deployment time so much, it may be just as efficient to redeploy the entire application as to redeploy only changed beans. In this case, incremental redeployment is optional.

The general procedure for using incremental deployment is as follows:

  1. Deploy an application with a large number of enterprise beans.

  2. Change a bean-related class file in an EJB module and rebuild the EJB JAR file (for

    example, myBeans-ejb.jar).

  3. Submit the updated EJB JAR to OC4J using any of the following tools:

    The following example shows how to use admin_client.jar for incremental deployment:

    java -jar admin_client.jar deployer:oc4j:rmis://localhost:23791 admin welcome
    -updateEJBModule -appName petstore -ejbModuleName myBeans-ejb.jar
    -file build/myBeans-ejb.jar
    
    
  4. Repeat steps 2 and 3.

For more information, see the Oracle Containers for J2EE Enterprise JavaBeans Developer's Guide.

Impact of EJB Redeployment on Application Clients

This section discusses the impact of EJB redeployment on existing clients, which differs depending on the type of EJBs used in the application. It includes the following topics:

Impact of Redeploying Session Beans

The following describe issues related to redeploying session beans.

Stateless Session Beans

For applications that include stateless session EJBs, the redeployment appears seamless to users, with no interruption in service. Existing requests will be served by current bean instances, while new requests will be served with new instances.

Stateful Session Beans

For an application or Web service that utilizes active stateful session EJB instances, you must explicitly specify a "persistence directory" where client state data will be persisted through serialization during the undeployment and redeployment processes. If this directory is not specified, all serialized state data will be lost during undeployment.

The persistence directory is defined in the <persistence> element within the orion-application.xml configuration file. This directory can also be set as the value of the persistencePath property through the deployment plan editor at the time the EJB archive is deployed. See "Setting Web Module Configuration Properties" for information.

Also note that for existing clients, a serialization-related exception will occur if there are any changes in the structure of the session beans deployed with the module.

Impact of Redeploying Entity Beans

The following sections describe issues related to redeploying entity beans.

Bean-Managed Persistence Beans

The application developer is responsible for handling any exceptions that may occur as a result of "hot deployment" of EJBs.

Container-Managed Persistence Beans

An unknown number of side effects may occur if the structure, types, and relationships of the container-managed fields within an EJB are changed. For this reason, OC4J should always be restarted after you make any changes.