bea.com | products | dev2dev | support | askBEA |
|
e-docs > WebLogic Server > Programming WebLogic Enterprise JavaBeans > Deploying EJBs to WebLogic Server |
Programming WebLogic Enterprise JavaBeans |
Deploying EJBs to WebLogic Server
The following sections provides instructions for deploying EJBs to WebLogic Server at WebLogic Server startup or on a running WebLogic Server. You can create, modify, and deploy EJBs in one or more instance of WebLogic Server. You can set up your EJB deployment, and map EJB references to actual resource factories, roles, and other EJBs available on a server by editing the XML deployment descriptor files.
Deploying EJBs at WebLogic Server Startup
To deploy EJBs automatically when WebLogic Server starts:
Compiling the container classes places the JAR file in the deployment directory. If you want the EJB to automatically deploy when WebLogic Server starts, place the EJB you want to deploy in the following directory:
mydomain\applications\DefaultWebApp directory
If your EJB JAR file is located in a different directory, make sure that you copy it to this directory if you want to deploy it at startup.
Deploying EJBs in Different Applications
When you deploy EJBs with remote calls to each other in different applications, you cannot use call-by-reference to invoke the EJBs. Instead, you use pass-by-value. You should place components that commonly interact with each other in the same application where call-by-reference can be used. By default, EJB methods called from within the same server pass arguments by reference. This increases the performance of method invocation because parameters are not copied. Pass-by-value is always necessary when EJBs are called remotely (not from within the server).
Deploying EJBs on a Running WebLogic Server
Although placing the EJB JAR file or deployment directory in the wlserver/config/mydomain/applications directory allows the EJB to be immediately deployed, if you make a change to the deployed EJB, you must redeploy the EJB for the changes to take effect.
Automatic deployment is provided for situations where rebooting WebLogic Server is not feasible and is for development purposes only. Using automatic deployment only deploys the updated EJB to the Administration Server and does not deploy the EJB to any Managed Server on the domain. Using automatic deployment features, you can:
Whether you deploy or update the EJB from the command line or the Administration Console, you use the automatic deployment features. The following sections describe automatic deployment concepts and procedures.
When you deploy an EJB JAR file or deployment directory, you specify a name for the deployment unit. This name is a shorthand reference to the EJB deployment that you can later use to undeploy or update the EJB.
When you deploy an EJB, WebLogic Server implicitly assigns a deployment name that matches the path and filename of the JAR file or deployment directory. You can use this assigned name to undeploy or update the bean after the server has started.
Note: The EJB deployment name remains active in WebLogic Server until the server is rebooted. Undeploying an EJB does not remove the associated deployment name, because you may later re-use that name to deploy the bean.
Deploying New EJBs into a Running Environment
To deploy an EJB JAR file or deployment directory that has not been deployed to WebLogic Server:
Undeploying an EJB effectively prohibits all clients from using the EJB. When you undeploy the EJB, the specified EJB's implementation class is immediately marked as unavailable in the server. WebLogic Server automatically removes the implementation class and propagates an UndeploymentException to all clients that were using the bean.
Undeployment does not automatically remove the specified EJB's public interface classes. Implementations of the home interface, remote interface, and any support classes referenced in the public interfaces, remain in the server until all references to those classes are released. At that point, the public classes may be removed due to normal Java garbage collection routines.
Similarly, undeploying an EJB does not remove the deployment name associated with the ejb.jar file or deployment directory. The deployment name remains in the server to allow for later updates of the EJB.
To undeploy a deployed EJB, use the following steps:
From the WebLogic Server Administration Console:
Undeploying an EJB does not remove the EJB deployment name from WebLogic Server. The EJB remains undeployed for the duration of the server session, as long as you do not change it once it had been undeployed. You cannot re-use the deployment name with the deploy argument until you reboot the server. You can re-use the deployment name to update the deployment, as described in the following section.
When you update the contents of an ejb.jar file or deployment directory that has been deployed to WebLogic Server, those updates are not reflected in WebLogic Server until:
Updating an EJB deployment enables an EJB provider to make changes to a deployed EJB's implementation classes, recompile, and then "refresh" the implementation classes in a running server.
When you update the currently-loaded implementation, classes for the EJB are immediately marked as unavailable in the server, and the EJB's classloader and associated classes are removed. At the same time, a new EJB classloader is created, which loads and maintains the revised EJB implementation classes.
When clients next acquire a reference to the EJB, their EJB method calls use the updated EJB implementation classes.
Note: You can update only the EJB implementation classes, as described in Loading EJB Classes into WebLogic Server. You cannot update the EJB's public interfaces, or any support classes that are used by the public interfaces. If you make any changes to the EJB's public classes and attempt to update the EJB, WebLogic Server displays an incompatible class change error when a client next uses the EJB instance.
To update or redeploy the EJB implementation class, use the following steps:
From the WebLogic Server Administration Console:
You can update only the EJB implementation class, not the public interfaces or public support classes
To create compiled EJB 2.0 JAR or EAR files:
To create compiled EJBs from previous versions of WebLogic Server:
mydomain\applications\DefaultWebApp directory
Note: You should manually recompile any EJBs from previous versions before deploying then to the EJB container. Otherwise, WebLogic Server automatically recompiles the EJBs and if there are errors, the output from the compile is sent to a separate log file.
If you change the contents of a compiled ejb.jar file in applications (by repackaging, recompiling, or copying over the existing ejb.jar), WebLogic Server automatically attempts to redeploy the ejb.jar file using the automatic 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 Files
The WebLogic Server container also enables you to automatically deploy JAR files that contain uncompiled EJB classes and interfaces. An uncompiled EJB 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.
After you package the uncompiled classes, simply copy the JAR into the wlserver\config\mydomain\applications directory. If necessary, WebLogic Server automatically runs javac (or a compiler you specify) to compile the .java files, and runs weblogic.appc to generate container classes. The compiled classes are copied into a new JAR file in mydomain\applications\DefaultWebApp, and deployed to the EJB container.
Should you ever modify an uncompiled ejb .jar in the applications directory (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.