# Ant EJB Tasks User Manual

## New JOnAS (Java Open Application Server) element for the current JOnAS version

The `<jonas>` nested element is used to build JOnAS-specific stubs and skeletons thanks to the `GenIC` specific tool, and construct a JAR file which may be deployed to the JOnAS Application Server. The build process will always determine if the EJB stubs/skeletons and the EJB-JAR file are up to date, and it will do the minimum amount of work required.

A naming convention for the EJB descriptors is most commonly used to specify the name for the completed JAR file. For example, if the EJB descriptor `ejb/Account-ejb-jar.xml` is found in the descriptor directory, the `<jonas>` element will search for a JOnAS-specific EJB descriptor file named `ejb/Account-jonas-ejb-jar.xml` and a JAR file named `ejb/Account.jar` will be written in the destination directory. But the `<jonas>` element can also use the JOnAS naming convention. With the same example as below, the EJB descriptor can also be named `ejb/Account.xml` (no base name terminator here) in the descriptor directory. Then the `<jonas>` element will search for a JOnAS-specific EJB descriptor file called `ejb/jonas-Account.xml`. This convention do not follow strictly the ejb-jar naming convention recommendation but is supported for backward compatibility with previous version of JOnAS.

Note that when the EJB descriptors are added to the JAR file, they are automatically renamed `META-INF/ejb-jar.xml` and `META-INF/jonas-ejb-jar.xml`.

Of course, this naming behavior can be modified by specifying attributes in the ejbjar task (for example, basejarname, basenameterminator, and flatdestdir) as well as the iplanet element (for example, suffix). Refer to the appropriate documentation for more details.

### Parameters:

Attribute | Description | Required
destdir | The base directory into which the generated JAR files will be written. Each JAR file is written in directories which correspond to their location within the "`descriptordir`" namespace. | Yes
jonasroot | The root directory for JOnAS. | Yes
classpath | The classpath used when generating EJB stubs and skeletons. If omitted, the classpath specified in the "ejbjar" parent task will be used. If specified, the classpath elements will be prepended to the classpath specified in the parent "ejbjar" task. A nested "classpath" elements may also be used. Note that the needed JOnAS JAR files are automatically added to the classpath according to the value of the orb attribute. | No
keepgenerated | `true` if the intermediate Java source files generated by GenIC must be deleted or not. If omitted, it defaults to `false`. | No
nocompil | `true` if the generated source files must not be compiled via the java and rmi compilers. If omitted, it defaults to `false`. | No
novalidation | `true` if the XML deployment descriptors must be parsed without validation. If omitted, it defaults to `false`. | No
javac | Java compiler to use. If omitted, it defaults to the value of `build.compiler` property. | No
javacopts | Options to pass to the java compiler. | No
rmicopts | Options to pass to the rmi compiler. | No
secpropag | `true` if the RMI Skel. and Stub. must be modified to implement the implicit propagation of the security context (the transactional context is always provided). If omitted, it defaults to `false`. | No
verbose | Indicates whether or not to use -verbose switch. If omitted, it defaults to `false`. | No
| additionalargs | Add additional args to GenIC. | No
keepgeneric | `true` if the generic JAR file used as input to GenIC must be retained. If omitted, it defaults to `false`. | No
suffix | String value appended to the JAR filename when creating each JAR. If omitted, it defaults to ".jar". | No
orb | Choose your ORB : RMI, JEREMIE, DAVID. The default is RMI. Note that the corresponding JOnAS JAR files are automatically added to the classpath. | Yes
nogenic | If this attribute is set to `true`, JOnAS's GenIC will not be run on the EJB JAR. Use this if you prefer to run GenIC at deployment time. If omitted, it defaults to `false`. | No
mappernames | List of JORM mapper names, separated by comma, used for CMP2.0 to indicate for which mappers the container classes should be generated. | No
jvmopts | Additional args to pass to the GenIC JVM. | No

As noted above, the jonas element supports additional <classpath> nested elements.

### Examples

This example shows ejbjar being used to generate deployment jars using a JOnAS EJB container. This example requires the naming standard to be used for the deployment descriptors. Using this format will create a EJB JAR file for each variation of '*-jar.xml' that is found in the deployment descriptor directory.

          <ejbjar srcdir="${build.classes}"
                  descriptordir="${descriptor.dir}">
            <jonas destdir="${deploymentjars.dir}"
                   jonasroot="${jonas.root}"
                   orb="RMI"/>
            <include name="**/*.xml"/>
            <exclude name="**/jonas-*.xml"/>
            <support dir="${build.classes}">
                 <include name="**/*.class"/>
            </support>
          </ejbjar>

This example shows ejbjar being used to generate a single deployment jar using a JOnAS EJB container. This example does require the deployment descriptors to use the naming standard. This will create only one ejb jar file - 'TheEJBJar.jar'.

          <ejbjar srcdir="${build.classes}"
                  descriptordir="${descriptor.dir}"
                  basejarname="TheEJBJar">
            <jonas destdir="${deploymentjars.dir}"
                   jonasroot="${jonas.root}"
                   suffix=".jar"
                   orb="${genic.org}"/>
            <include name="**/ejb-jar.xml"/>
            <exclude name="**/jonas-ejb-jar.xml"/>
          </ejbjar>