An enterprise bean is a Java component that can be combined with
other resources to create Java 2 Platform, Enterprise Edition (J2EE) applications.
Before you begin
This article assumes that you have created and unit tested an
enterprise bean (EJB file) that
you want to assemble in an
enterprise
application and deploy onto an application server.
Why and when to perform this task
In an Application Server Toolkit (AST) or Rational Web Developer
assembly tool, you can
create and test enterprise beans that conform to the distributed component
architecture defined in the Sun Microsystems Enterprise JavaBeans (EJB) specification
and that support extended functionality for WebSphere Application Server.
You
can create enterprise beans (either with or without inheritance) such as session
beans, container-managed persistence (CMP) entity beans, bean-managed persistence
(BMP) entity beans, or message-driven beans. Using the EJB deployment descriptor
editor of an assembly tool, you can set deployment descriptor and assembly
properties for enterprise beans.
This article describes how to create
an EJB project (or EJB module)
using an assembly tool.
Steps for this task
- Start an assembly tool.
- If you have not done so already, configure the assembly tool for work on J2EE modules.
Ensure that the J2EE capability is enabled.
- Click File > New > Project > EJB > EJB Project > Next. Or,
if you have created a J2EE project before, click File > New > EJB Project.
- In the New EJB Project dialog:
- Name the EJB project and specify its location. To
change the default project location, click Browse and specify a new
location. If you specify a non-default project location that is already being
used by another project, you cannot create the project.
- Select the EJB specification version to which you want your
EJB project to adhere. If you plan on using EJB 2.1 enterprise
beans, you must specify an EJB 2.1 project. You can add EJB 1.1 enterprise
beans to an EJB 2.1 project. An EJB 2.1 project must exist in a J2EE 1.4 enterprise
application project. An EJB 2.0 project can exist in a J2EE 1.4 or 1.3 enterprise
application project. Your available options can differ, depending on the J2EE
preferences defined.
- Select a target server. Select the WebSphere
Application Server v6.0 target server to use Version 6 WebSphere Application
Server capabilities.
- If you want to add EJB components to an enterprise application
(EAR file), select Add module to an EAR project.
- Specify a new or existing enterprise application (EAR) project
to be associated with your new EJB project for purposes of deployment.
Select an existing enterprise application project from the drop-down
list or type a new project name. Or, click New and create a new enterprise application. Note that if you type
a new EAR project name, the EAR project is created in the default location
with the lowest compatible J2EE version based on the version of the project
being created. If you want to specify a different version or a different location
for the enterprise application, you must click New and create a new
enterprise application.
- Specify whether you want to add support for annotated Java classes
to the EJB module.
- Specify whether you want to create a default stateless session
bean.
- Optional: If you are creating a new enterprise application
project or if you have no module dependencies to specify, skip this step.
Otherwise, click Next to create an EJB client JAR file from your existing
enterprise bean. On the EJB Client JAR Creation page, specify
a URI, name and project location for the EJB client JAR file. If you have
no module dependencies to specify, skip the rest of this step; otherwise,
click Next. On the Module Dependencies page, select dependent
JAR files or modules within the associated enterprise application project.
This updates the runtime class-path and Java project build path with the appropriate
JAR files. Application client modules, EJB modules, and Web modules can all
have dependencies on EJB modules or utility JAR files. Modules cannot depend
on WAR or application client JAR files.
- Click Finish to create the EJB project.
Result
A new EJB project is created, reflecting the J2EE folder structure
that specifies the location of enterprise bean content files, class files,
class paths, the deployment descriptor, and supporting metadata. Files for
the EJB project are shown in the Project Explorer view under
Enterprise
Applications and
EJB Projects.
What to do next
After you have an EJB project to hold enterprise beans, you can do
the following:
For detailed instructions on creating CMP fields or CMP finder methods
for entity beans, relating CMP fields, adding methods to interfaces, or managing
enterprise beans, refer to articles under EJB assembly in the Application
Server Toolkit information center that accompanies this information center.