![]() |
![]() |
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.
The following sections are written primarily for:
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 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:
Deploying Pinned EJBs - Special Step Required
There is a known issue with deploying or redeploying EJBs to a single server instance in a cluster—referred to as pinned deployment—if the .jar file contains contain uncompiled classes and interfaces.
During deployment, the uncompiled EJB is copied to each server instance in the cluster, but it is compiled only on the server instance to which it has been deployed. As a result, the server instances in the cluster to which the EJB was not targeted lack the classes generated during compilation that are necessary to invoke the EJB. When a client on another server instance tries to invoke the pinned EJB, it fails, and an Assertion error is thrown in the RMI layer.
If you are deploying or redeploying an EJB to a single server instance in a cluster, compile the EJB with ejbc before deploying it, to ensure that the generated classes copied to all server instances available to all nodes in the cluster.
For more information on pinned deployments, see Setting Up WebLogic Clusters.
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 change a deployed EJB's classes, these changes are not reflected in WebLogic Server until:
Redeploying an EJB deployment enables an EJB provider to make changes to a deployed EJB's classes, recompile, and then "refresh" the classes in a running server.
When you redeploy, the classes currently loaded 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 classes.
When clients next acquire a reference to the EJB, their EJB method calls use the changed EJB classes.
You can redeploy an EJB that is standalone or part of an application, using the weblogic.Deployer tool or via the Administration Console.
To redeploy using weblogic.Deployer:
To redeploy via the WebLogic Server Administration Console:
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.
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.ejbc 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.
Deployment Restriction with Container Managed Relationships
Two EJBs that have a container-managed relationship must be deployed in the same JAR file. For more information on container-managed relationships, see Container-Managed Relationships.
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |