Deploying enterprise beans
Deploying an enterprise bean to an application server usually involves the following steps:
- Creating a deployment descriptor XML-based file compliant with Sun's EJB 1.1 specification.
When you use JBuilder's EJB wizards to create your beans, the deployment descriptors are being created at the same time for you.
- Editing the environment properties that an EJB requires at runtime, if necessary.
You can edit environment properties using JBuilder's Deployment Descriptor editor.
- Creating an EJB JAR file containing the deployment descriptor and all of the classes required to operate the EJB (bean class, remote interface, home interface, stubs and skeletons, primary key class if the EJB is an entity bean, and any other associated classes).
When you compile your EJB group using the JBuilder development environment, the proper JAR file is created for you.
- Deploying your EJB to an EJB container.
JBuilder has an EJB Deployment wizard that simplifies the deployment process for Inprise enterprise beans. If WebLogic Server is your target application server, choosing Tools|EJB Deployment invokes WebLogic's EJB deployment tool. In general, JBuilder uses the deployment tool associated with the application server you selected for the current project if such a tool is available.
Creating a deployment descriptor file
As you create your enterprise beans using JBuilder's EJB tools, JBuilder is creating deployment descriptors at the same time. You can then use the Deployment Descriptor editor to add additional information and modify attributes in the deployment descriptors.
Each deployment descriptor must conform to the following requirements according to the EJB 1.1 specification:
When you use JBuilder's EJB tools to create and edit your deployment descriptors, you don't have to worry about learning XML or conforming to the semantics rules specified in Sun's DTD. The Deployment Descriptor editor imposes these rules on the data you enter and edit. As you fill in information using the Deployment Descriptor editor, it lets you know what data are required. JBuilder's tools automatically set up the Inprise-specific extensions in an ejb-inprise.xml file. For more information about the Deployment Descriptor editor, see "Using the Deployment Descriptor editor."
The role of the deployment descriptor
The role of the deployment descriptor is to provide information about each EJB that is to be bundled and deployed in a particular JAR file. It's intended to be used by the consumer of the EJB JAR file. As the bean developer, it's your responsibility to create the deployment descriptor. You can also modify the deployment descriptor once the enterprise bean is deployed.
The information in the deployment descriptor is used in setting enterprise bean attributes. These attributes define how the enterprise bean operates within a particular environment. For example, when you set the bean's transactional attributes, they define how the bean behaves with respect to transactions. The deployment descriptor keeps the following information:
- Type information, which defines the types, or names, of the classes for the home and remote interfaces and the bean class.
- JNDI names, which set the name under which the home interface of the enterprise bean is registered.
- Fields to enable container-managed persistence.
- Transactional policies that govern the transactional behavior of a bean.
- Security attributes that govern access to an enterprise bean.
- Inprise-specific information, such as data source information used for connections to a database.
The types of information in the deployment descriptor
The information in the deployment descriptor can be divided into two basic kinds:
- Enterprise beans' structural information.
Structural information describes the structure of an enterprise bean and declares an enterprise bean's external dependencies. This information is required. The structural information usually can't be changed because doing so could break the bean's function.
- Application assembly information.
Application assembly information describes how the enterprise bean(s) included in the ejb-jar.xml
file are composed into a larger application deployment unit. This information is optional. Assembly level information can be changed without breaking the bean's function, although doing so might alter the behavior of an assembled application.
Structural information
The bean developer must provide the following structural information for each bean in the EJB jar:
All enterprise beans
- Enterprise bean's name, a mnemonic used to refer to the bean in the deployment descriptor.
- Enterprise bean's class
- Enterprise bean's home interface
- Enterprise bean's remote interface
- Enterprise bean's type, either session bean or entity bean
- Environment entries, if the bean has configuration parameters
- Resource factory references, if a data source is used
- EJB references, if an enterprise bean references another enterprise bean
- Security role references, if an enterprise bean needs to access specific roles
Enterprise session beans
- Session bean state management type, either stateful or stateless
- Session bean transaction demarcation type for stateful beans that have synchronization callbacks
Enterprise entity beans
- Entity bean's persistence management type
- Entity bean's primary key class
- Container-managed fields for container-managed beans
Application assembly information
You can specify any of the following application assembly information. During application assembly, this information is optional. This same information is not optional for the role of the deployer
- Binding of enterprise bean references
- Security roles
- Method permissions
- Linking of security role references
- Transaction attributes
During the process of application assembly or deployment, you can modify the following structural information:
- The values of environment entries. The application assembler can change existing properties and/or define the values of environment properties.
- Description fields. The application assembler can change existing descriptions or create new description elements.
You can't modify any other types of structural information. You can modify any application assembly information at deployment time, however.
Security
The application assembler usually specifies the following information in the deployment descriptor:
- Security roles
- Method permissions
- Links between security role references and security roles
Security roles
Using the security role elements in the deployment descriptor, the developer can define one or more security roles. These define the required security roles for the clients of the enterprise beans.
Method permissions
Using the method-permission elements in the deployment descriptor, the developer can define method permissions. Method permissions are paired relations between the security roles and the methods of the enterprise bean's remote and home interfaces.
Linking of security role references
If security roles are defined, the developer must link them with security role references using the role-link element in the deployment descriptor.
If your target application server is the Inprise Application Server, you'll have an additional deployment descriptor for you enterprise bean, ejb-inprise.xml
. To read more about Inprise-specific information in deployment descriptors, see the "Deploying Enterprise JavaBeans" chapter of the Inprise Application Server's Enterprise JavaBeans Programmer's Guide.
Deploying to an application server
When your bean is working to your satisfaction and if you selected the Inprise Application Server as your application server for your current project, you can deploy your bean to the Inprise Application Server using JBuilder's EJB Deployment wizard.
Start the application server, then use the EJB Deployment wizard. The steps explained here assume you are deploying to the Inprise container. If your target application server is the WebLogic server, choosing Tools|EJB Deployment wizard displays the WebLogic Deployer Tool.
Deploying a single JAR file
These are the steps for deploying a single JAR file:
- Choose Tools|EJB Deployment wizard.
- Select the Quick mode option.
You can check Verbose Output if you want to see all the details.
- Click Next.
- Use the Browse button to locate the JAR file containing your bean.
- Select the container you want to deploy your bean. If there is only one server running at the time, it will be selected automatically.
- If you want stubs to be generated, check the Generate Stubs check box.
- Click Next to see the next page.
The wizard attempts to deploy the bean and reports its status to you on the page:
- Click Finish.
Deploying multiple JAR files
If you have multiple JARs to deploy or complex deployment requirements, use the Advanced mode of the EJB Deployment wizard, which involves several more steps:
- Choose Tools|EJB Deployment wizard.
- Select the Advanced mode option and click Next.
- Use the Add button to locate the JAR files you want to deploy and click Next.
The wizard analyzes the selected JARs and reports its result on this page indicating the type of deployment descriptors it found.
- Click Next.
- Specify your desired Stub Generation and Java2IIOP options and click Next.
- Specify your desired Packaging and Verifier options and click Next.
The wizard generates any necessary stubs, packages the JARs, and verifies them, reporting the results on this page.
- Click Next to go to the next step.
- Using the Add button, select the running containers you want to deploy your JARs.
- Specify any Post-Deployment Action options you want and click Next.
The final page displays, showing the results of the deployment:
- Click Finish.