| Red Hat Application Server: JOnAS User Guide | ||
|---|---|---|
| Prev | Chapter 15. Application Deployment and Installation Guide | Next |
For this example, it is assumed that you want to customize the deployment of the AccountImpl bean in the JOnAS example examples/src/eb by changing the name of the database table used for the persistence of the AccountImpl.
The current directory is $JONAS_ROOT/examples/src/eb. Do the following:
Edit jonas-ejb-jar.xml and modify the value of the <jdbc-table-name> element included in the <jdbc-mapping> element corresponding to AccountImpl entity.
Compile all the .java files present in this directory:
javac -d ../../classes Account.java AccountImplBean.java AccountExplBean.java AccountHome.java ClientAccount.java |
Perform the deployment:
Build an EJB-JAR file named ejb-jar.jar with all the corresponding classes and the two deployment descriptors:
mkdir -p ../../classes/META-INF cp ejb-jar.xml ../../classes/META-INF/ejb-jar.xml cp jonas-ejb-jar.xml ../../classes/META-INF/jonas-ejb-jar.xml cd ../../classes jar cvf eb/ejb-jar.jar META-INF/ejb-jar.xml META-INF/jonas-ejb-jar.xml eb/Account.class eb/AccountExplBean.class eb/AccountHome.class eb/AccountImplBean.class |
From the source directory, run the GenIC generation tool that will generate the final ejb-jar.jar file with the interposition classes:
GenIC -d ../../classes ejb-jar.jar |
Install the EJB-JAR in the $JONAS_ROOT/ejbjars directory:
cp ../../classes/eb/ejb-jar.jar $JONAS_ROOT/ejbjars/ejb-jar.jar |
The JOnAS application Server can now be launched using the command:
service jonas start |
The steps just described for building the new ejb-jar.jar file explain the deployment process. It is generally implemented by an ANT build script.
If Apache ANT is installed on your machine, type ant install in the $JONAS_ROOT/examples/src directory to build and install all ejb-jar.jar files for the examples.
To write a build.xml file for ANT, use the ejbjar task, which is one of the optional EJB tasks defined in ANT (see http://jakarta.apache.org/ant/manual/index.html). The ejbjar task contains a nested element called jonas, which implements the deployment process described above (interposition classes generation and EJB-JAR file update).
Generally, the $JONAS_ROOT/lib/common/ow_jonas_ant.jar file has the most up-to-date version of the EJB task containing an updated implementation of the jonas nested element. See Chapter 27 Ant EJB Tasks: Using EJB-JAR for information on the jonas nested element.
For example, $JONAS_ROOT/examples/src/alarm/build.xml contains this code snippet:
<!-- ejbjar task -->
<taskdef name="ejbjar"
classname="org.objectweb.jonas.ant.EjbJar"
classpath="${jonas.root}/lib/common/ow_jonas_ant.jar" />
<!-- Deploying ejbjars via ejbjar task -->
<target name="jonasejbjar"
description="Build and deploy the ejb-jar file"
depends="compile" >
<ejbjar basejarname="alarm"
srcdir="${classes.dir}"
descriptordir="${src.dir}/beans/org/objectweb/alarm/beans"
dependency="full">
<include name="**/alarm.xml"/>
<support dir="${classes.dir}">
<include name="**/ViewProxy.class"/>
</support>
<jonas destdir="${dist.ejbjars.dir}"
jonasroot="${jonas.root}"
mappernames="${mapper.names}"
protocols="${protocols.names}" />
</ejbjar>
</target> |