15.2. Example of Deploying and Installing an EJB Using an EJB-JAR File

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:

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>