Express (Distributed operating systems), v8.0 > Develop and deploying applications > Rapid deployment of J2EE applications > Constructing a J2EE application from artifacts > Dropping J2EE artifacts into a free-form project
Add and deleting enterprise beans to a free-form project
We can drop enterprise bean (EJB) artifacts or module files (ejb.jar) into a free-form project. The EJB artifacts can be annotated or non-annotated; they can contain source or compiled classes. The EJB artifacts include the EJB classes or the EJB interfaces (remote, local, home, and primary key class for entity beans).
Before you begin
Restriction: We can use the rapid deployment tools for packaging applications at J2EE 1.3 or 1.4 specification-levels. However, the rapid deployment tools do not support Java EE 5.0 (or later) nor J2EE 1.2 specification-level. For tools support of deploying Java EE 5 and later modules, you can use the monitored directory starting in WAS V8.0 release. For more details about the monitored directory, see Ways to install enterprise applications or modules and Installing enterprise application files by adding them to a monitored directory topics.
Prerequisites
- Prior to dropping EJB module files (ejb.jar) into a free-form project, generate the deployment code. The ejbDeploy tools do not automatically run on these already packaged ejb.jar files.
- If you drop an entity bean, by default the rapid deployment tools generate a bean-managed persistence (BMP) entry in the deployment descriptor. If you want a container-managed persistence (CMP) bean, this needs to be specified using annotated source file.
- A naming convention must be followed for the Java source, compiled class, or annotated source files for each enterprise bean. For example, if an enterprise bean implementation class is named MySessionBean.java, follow this convention for any bean interfaces that are defined:
- The home interface class must be named MySessionHome.java
- The remote interface class must be named MySession.java
- The local interface class must be named MySessionLocal.java
- The local home interface class must be named MySessionLocalHome.java
- The primary key class for entity beans can be named anything because the rapid deployment tools logically locate the correct class name by introspecting either the home or local home interface.
These rules do not imply that both remote and local view types must be created; these are just naming conventions when creating source for a set of bean interfaces.
A new EJB entry to the deployment descriptor is only added when a minimum set of resources are available in the free-form project. For example, if the bean class is placed in the free-form project, its compiled class maps to the EJB project but no deployment descriptor entry is created until the rapid deployment tools locate either a set of remote view type classes or local view type classes. For entity beans, a primary key class is also required. If the minimum resources are removed, the bean descriptor entry is removed. The examples section of this topic provides a concrete example of these rules.
Procedure
- Use your file management system to place your EJB artifacts properly into the free-form project. The directory name of the free-form project has the same string value providedd for the -project parameter used in the wrd-config command.
- The following activities occur when you drop EJB artifacts into a free-form project:
- The EJB interface classes are mapped into the imported classes folder of the EJB client JAR project.
- The EJB classes are mapped into the imported classes folder of the EJB module project.
- A new enterprise bean entry is created in the deployment descriptor (found in the ejbModule\META-INF\ejb-jar.xml file in the EJB module project).
- A new enterprise bean binding is created in the bindings with a default JNDI name.
- The application is synchronized with the server.
- (Optional) Use the Universal Test Client to test your enterprise beans.
Example
This example shows the activities of the bean entry in the deployment descriptor when EJB resources are added and removed from the free-form project.
Tip: To monitor rapid deployment activities, run your rapid deployment session with console output. Run the rapid deployment launch tool as follows:
wrd.bat -monitor
wrd.sh -monitor
- The console output can look like this when adding an enterprise bean Java source file (called MyEJBBean.java), remote interface Java source file (called MyEJB.java), and home interface (called MyEJBHome.java) to a free-form project (called MyProject):
[08:47:25 PM] [/MyProject/ejbs/MyEJB.java] Added [08:47:25 PM] [/MyProject/ejbs/MyEJBBean.java] Added [08:47:25 PM] [/MyProject/ejbs/MyEJBHome.java] Added [08:47:30 PM] [/MyProject/bin/ejbs/MyEJB.class] copied to project [MyProjectEJBClient] [08:47:30 PM] [/MyProject/bin/ejbs/MyEJBBean.class] copied to project [MyProjectEJB] [08:47:30 PM] [/MyProject/bin/ejbs/MyEJBHome.class] copied to project [MyProjectEJBClient] [08:47:32 PM] Enterprise bean added to ejb-jar.xml: MyEJB [08:47:32 PM] Enterprise bean binding for [MyEJB] added to ejb-jar-bnd.xmi. JNDI Name is: [ejb/MyEJBBean]A new enterprise bean entry is created in the deployment descriptor (found in the ejbModule\META-INF\ejb-jar.xml file in the EJB module project):<session id="Session_1092185252700"> <ejb-name>MyEJB </ejb-name> <home>ejbs.MyEJBHome </home> <remote>ejbs.MyEJB </remote> <ejb-class>ejbs.MyEJBBean </ejb-class> <session-type>Stateless </session-type> <transaction-type>Container </transaction-type> </session>A new enterprise bean binding is created in the bindings with a default JNDI name. The ibm-ejb-bnd.xmi file might contain the following entries:<ejbBindings xmi:id="EnterpriseBeanBinding_1092185252700" jndiName="ejb/MyEJBBean"> <enterpriseBean xmi:type="ejb:Session" href="META-INF/ejb-jar.xml#Session_1092185252700"/> </ejbBindings>- The console output can look like this example when adding a local interface (called MyEJBLocal.java) and local home interface (called MyEJBLocalHome.java) for the same bean in the same free-form project:
[08:52:59 PM] [/MyProject/ejbs/MyEJBLocal.java] Added [08:52:59 PM] [/MyProject/ejbs/MyEJBLocalHome.java] Added [08:52:59 PM] [/MyProject/bin/ejbs/MyEJBLocal.class] copied to project [MyProjectEJBClient] [08:52:59 PM] [/MyProject/bin/ejbs/MyEJBLocalHome.class] copied to project [MyProjectEJBClient] [08:53:01 PM] Local view type added for ejb: MyEJBAn update is made to the existing deployment descriptor (found in the ejbModule\META-INF\ejb-jar.xml file in the EJB module project):<session id="Session_1092185252700"> <ejb-name>MyEJB </ejb-name> <home>ejbs.MyEJBHome </home> <remote>ejbs.MyEJB </remote> <local-home>ejbs.MyEJBLocalHome </local-home> <local>ejbs.MyEJBLocal </local> <ejb-class>ejbs.MyEJBBean </ejb-class> <session-type>Stateless </session-type> <transaction-type>Container </transaction-type> </session>- The console output can look like this example when the local interface (called MyEJBLocal.java) is removed from the same free-form project:
[08:56:27 PM] [/MyProject/bin/ejbs/MyEJBLocal.class] Deleted [08:56:27 PM] [/MyProject/ejbs/MyEJBLocal.java] Deleted [08:56:28 PM] Local view type removed ejb: MyEJBSince the local interface was removed from the free-form project and the existing local home interface is not sufficient to define a local view type the bean deployment descriptor (found in the ejbModule\META-INF\ejb-jar.xml file in the EJB module project) is updated to reflect the removal of the local view type:<session id="Session_1092185252700"> <ejb-name>MyEJB </ejb-name> <home>ejbs.MyEJBHome </home> <remote>ejbs.MyEJB </remote> <ejb-class>ejbs.MyEJBBean </ejb-class> <session-type>Stateless </session-type> <transaction-type>Container </transaction-type> </session>- The console output can look like this example when the remote interface (called MyEJB.java) is removed from the same free-form project:
[09:00:04 PM] [/MyProject/bin/ejbs/MyEJB.class] Deleted [09:00:04 PM] [/MyProject/ejbs/MyEJB.java] Deleted [09:00:09 PM] Enterprise bean removed from ejb-jar.xml: MyEJBSince the remote interface has been removed from the free-form project, the existing home interface is not sufficient to define a remote view type. Both the remote and local view types are not defined, so the bean and its bindings are removed from the deployment descriptor.
Feedback