BEA Logo BEA WebLogic Server Release 6.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

   Programming WebLogic Enterprise JavaBeans:   Previous topic   |   Next topic   |   Contents   

 

Deploying EJBs in the EJB Container

 

The BEA WebLogic Server container provides simplified methods for deploying and redeploying EJBs. The following sections describe how to deploy EJBs into the EJB 2.0 container.

You can continue to deploy EJB 1.1 beans into the EJB 1.1 container by using the instructions in Deploying EJBs in a Running WebLogic Server (Dynamic Deployment). You should become familiar with those EJB 1.1 instructions before attempting to deploy EJB 2.0 beans.

Roles and Responsibilities

The following sections are written primarily for:

With WebLogic Server, you can create, modify, and deploy EJBs in one or more WebLogic Servers. You can set up your EJB deployments, and map EJB references to actual resource factories, roles, and other EJBs available on a server by editing the XML.

WebLogic Server Deployment Files

To modify the deployment properties, you need to update the XML deployment descriptor dtds in the XML files.

The weblogic-ejb-jar.xml contains descriptors that define the caching, clustering, and performance behavior of EJBs. It also contains descriptors that map available WebLogic Server resources to EJBs. WebLogic Server resources include security role names, data sources such as JDBC pools and JMS connection factories, and other deployed EJBs. Descriptors for container-managed persistence services are available in weblogic-cmp-rdbms.xml.

Descriptors in weblogic-ejb-jar.xml are linked to EJB names in ejb-jar.xml, resource names in a running WebLogic Server, and to persistence type data defined in weblogic-cmp-rdbms-jar.xml (for entity EJBs using RDBMS persistence). The following figure shows the relationship among these components.

See Manually Editing XML Deployment Files to manually edit the XML deployment files.

Automatic Deployment Directory

The weblogic/config/domain/applications directory acts as an automatic deployment directory for EJB .jar files and EJB .jar deployment directories. When you start WebLogic Server, it automatically deploys any valid EJB .jar files or .jar directories that reside in the applications directory.

WebLogic Server also checks the contents of applications every ten seconds to determine whether an EJB deployment has changed. If a deployment has changed, it is automatically redeployed using the dynamic deployment feature.

See the sections below for more information on deploying and redeploying compiled .jar files, uncompiled .jar files, and .jar directories using the applications directory.

Note: WebLogic Server Version 6.0 also uses a new $wl_temp_do_not_delete directory to copy EJB .jar files before deploying them into the EJB container. You should not add, remove, or modify files in this directory, nor should you delete this directory while the server is running.

The home and remote interfaces for an EJB are required in the classpath of any calling conponent. When the EJB classes are compiled, they can be placed in the a directory in the classpath, such as .../config/<domain>/clientclasses.

Deploying Compiled EJB .jar Files

You create compiled EJB 2.0 .jar files by:

  1. Compiling your EJB classes and interfaces using javac.

  2. Packaging the EJB classes and interfaces into a valid .jar file.

  3. Using weblogic.ejbc on the .jar file to generate WebLogic Server container classes.

These steps are similar to the steps required for compiling and deploying EJB 1.1 beans.

You may already have compiled .jar files that you used for deploying EJBs to the container in WebLogic Server Version 6.0 EJB 1.1 container. To deploy these files to the EJB 2.0 container:

  1. Run weblogic.ejbc against the .jar file to generate EJB 2.0 container-classes.

  2. Copy the compiled .jar files into weblogic/config/domain/applications.

    Note: The container does not support deploying EJB 1.1-compliant CMP entity beans into the EJB 2.0 container. If you have EJB 1.1-compliant CMP beans, you must deploy them into the EJB 1.1 container.

If you change the contents of a compiled EJB .jar file in applications (by repackaging, recompiling, or copying over the existing .jar file), WebLogic Server automatically attempts to redeploy the .jar using the dynamic deployment feature.

Note: Because the automatic redeployment feature uses dynamic deployment, WebLogic Server can only redeploy an EJB's implementation classes. You cannot redeploy an EJB's public interfaces.

Deploying Uncompiled EJB .jar Files

The WebLogic Server container also enables you to automatically deploy .jar files that contain uncompiled EJB classes and interfaces. An uncompiled EJB .jar file has the same structure as a compiled file, with the following exceptions:

The .java or .class files in the .jar file must still be packaged in subdirectories that match their Java package hierarchy. Also, as with all EJB .jar files, you must include the appropriate XML deployment files in a top-level META-INF directory.

Once you have packaged the uncompiled classes, simply copy the .jar into the %BEA_HOME%\wlserver6.0\config\<your domain>\applications directory. If necessary, WebLogic Server automatically runs javac (or a compiler you specify) to compile the .java files, and runs weblogic.ejbc to generate container classes. The compiled classes are copied into a new .jar file in weblogic/config/examples/applications, and deployed to the EJB container.

Should you ever modify an uncompiled .jar in applications (either by repackaging or copying over the .jar file), WebLogic Server automatically recompiles and redeploys the .jar using the same steps.

Note: Because the automatic redeployment feature uses dynamic deployment, WebLogic Server can only redeploy an EJB's implementation classes. You cannot redeploy an EJB's public interfaces.

Deploying from an EJB .jar Directory

The EJB 2.0 container also enables you to deploy EJBs using an EJB .jar subdirectory in the applications directory. Using this method is similar to using an uncompiled .jar file, in that you do not need to compile EJB classes and interfaces, and you do not need to run weblogic.ejbc. Using a .jar subdirectory also removes the requirement for packaging the EJB deployment into a .jar file. You simply create a subdirectory in applications that has the same structure of an EJB .jar file.

For example, the following files define a valid EJB .jar deployment directory for use with the WebLogic Server EJB 2.0 container:

When you use an EJB .jar directory in this manner, WebLogic Server automatically redeploys the EJB when the ejb-jar.xml deployment file has changed. If you are developing a new EJB using a .jar directory, you can trigger redeployment by changing the timestamp of ejb-jar.xml (on UNIX systems, use the touch command; on Windows NT, open and save the file in a text editor).