27.2. GenIC Ant Task

27.2.1. Why is there a new task?

Previous versions of the JOnAS EjbJar Ant task have some limitations—especially when you are developing webservices.

In previous versions of JOnAS, jonas-ejb-jar constructed the JAR for you, using information gathered from the ejb-jar.xml and from the classes themselves (dependencies using BCEL). But if you have a Session Bean exposed as a webservice, you want to have more files in your archive (webservices.xml, JAX-RPC mapping file, WSDL + imported WSDL definitions + imported XML Schema).

The older task did not package these files inside the archive, and therefore, when GenIC loaded the descriptors, some dependencies were missing, causing GenIC to throw an exception.

The solution is to let the developer create the JAR file, so that the exact content of the file can be controlled.

The file should have at least the following content:

Notice that webservices files are optional.

27.2.2. Task Attributes

The genic task supports most attributes of the jonas-ejb-jar task.

Differences:

 

 

AttributeDescriptionRequired
jonasrootThe root directory for JOnAS.Yes (Can be read from project properties if not set)
jonasbaseThe base directory for JOnAS. If omitted, it defaults to jonasroot.No
keepgeneratedtrue if the intermediate Java source files generated by GenIC must not be deleted. If omitted, it defaults to false.No
nocompiltrue if the generated source files must not be compiled via the Java and RMI compilers. If omitted, it defaults to false.No
validationtrue if the XML deployment descriptors must be parsed with validation. If omitted, it defaults to true.No
javacJava compiler to use. If omitted, it defaults to the value of build.compiler property.No
javacoptsOptions to pass to the Java compiler.No
protocolsComma-separated list of protocols (chosen from jeremie, jrmp, iiop, cmi) for which stubs should be generated. Default is jrmp,jeremie.No
rmicoptsOptions to pass to the RMI compiler.No
verboseIndicates whether or not to use -verbose switch. If omitted, it defaults to false.No
additionalargsAdd additional arguments to GenIC.No
jvmoptsAdditional arguments to pass to the GenIC JVM.No
jvmdebugIndicates whether you want to debug the forked JVM; it defaults to false. The JVM will be suspended and waiting a connection on port 12345.No

Nested ElementDescriptionRequired
classpathThe additional classpath entries used when generating EJB stubs and skeletons.No
filesetPoints out the ejb-jars that will be processed by GenIC. Note that you can add as many filesets as you want (useful if your JARs are in different directories).Yes (at least 1)

  1. First, define this new task:
     
    <taskdef name="genic"
        classname="org.objectweb.jonas.ant.GenICTask"
        classpath="${jonas.root}/lib/common/ow_jonas_ant.jar" />

  2. Then use it:

    1. Create the JAR file.

      <jar destfile="${temp.ejbjars.dir}/my-ejbjar.jar">
          <metainf dir="${etc.dir}/META-INF" />
          <fileset dir="${classes.dir}">
              <include name="org/objectweb/jonas/myejbjar/*.class" />
          </fileset>
      </jar>
    2. Process this JAR with the GenIC task.

      <genic keepgenerated="true"
             protocols="${protocols.names}">
          <fileset dir="${temp.dir}">
              <include name="ejbjars/my-ejbjar.jar" />
          </fileset>
      </genic>

Example 27-1. Example