How Do I: Add an Existing Enterprise JavaBean to an Application?

WebLogic Workshop provides the EJB control to enable convenient access to an existing Enterprise JavaBean (EJB) from web services. To use this EJB with an EJB control, you must first make the EJB known to your application. You can do this by adding an EJB JAR as a module or as a library.

When you add an EJB JAR as a module, the EJB will be deployed on the server as part of that application.

Instead of the EJB having application scope, you can also deploy an EJB in a standalone fashion, that is, the JAR file is deployed directly on the server (and is not wrapped in an application's EAR file). For more information, see How Do I: Deploy a Stand-Alone Enterprise JavaBean on WebLogic Server? When the EJB is deployed as a standalone on the server used by your application, you can add this EJB's complete JAR or its client JAR as a library. The EJB client JAR contains the EJB's home and remote interface classes and any other classes necessary for a client program to access the EJB.

Note. You can specify the creation of a EJB client JAR in EJB project. For more information, see @ejbgen:jar-settings Annotation.

When you add an EJB JAR as a library, it is recommended that you use the client JAR. The client JAR file contains only the classes and interfaces used to access EJBs, and using this JAR provides better code isolation between the EJB's client and server code.

Note. You should never add the same EJB both as a module and as a library, because it is unclear at this point whether the EJB Control is talking to the globally-scoped or application-scoped version of the EJB.

To Add a JAR File as a J2EE Module

  1. On the Applications tab of your application, locate the Modules folder.
  2. Right-click the Modules folder, then click Add Module.
  3. In the Add Module dialog, browse to the JAR file you want to add.
  4. Select the JAR file, then click Open.

    Remember that this must be a complete EJB JAR file, and not the EJB's client JAR. WebLogic Workshop will warn you if the JAR file is not a valid J2EE module.

After you have added the module, WebLogic Workshop puts the JAR file in your application's root folder. Classes in the JAR are added to your application's class path, and the JAR will be deployed to the server as a J2EE module.

To Add a JAR File as a Library

  1. On the Applications tab for your application, locate the Libraries folder.
  2. Right-click the Libraries folder, then click Add Library.
  3. In the Add Library dialog, browse to the JAR file you want to add.
  4. Select the JAR file, then click Open.

    If the JAR file is a J2EE module, WebLogic Workshop will ask if you want to add it as a module or as a library.

After you have added the EJB as a library, WebLogic Workshop puts the JAR file in your application's app-inf/lib folder. Classes in the JAR are added to your application's class path, but the JAR is not deployed as a J2EE module.

Related Topics

How Do I: Deploy a Stand-Alone Enterprise JavaBean on WebLogic Server?

Developing Enterprise JavaBeans

EJB Control