Assembling (or packaging) modules and applications in Application Server conforms to all of the customary Java-EE-defined specifications. The only difference is that when you assemble in Application Server, you include Application Server specific deployment descriptors that enhance the functionality of the Application Server.
For example, when you assemble an EJB JAR module, you annotate or create two deployment descriptor files with these names: ejb-jar.xml and sun-ejb-jar.xml. If the EJB component is an entity bean with container-managed persistence, you can also create a .dbschema file and a sun-cmp-mapping.xml file. For more information about sun-ejb-jar.xml and sun-cmp-mapping.xml, see Appendix A, Deployment Descriptor Files.
According to the Java EE specification, section 8.1.1.2, “Dependencies,” you cannot package utility classes within an individually deployed EJB module. Instead, package the EJB module and utility JAR within an application using the JAR Extension Mechanism Architecture. For other alternatives, see Chapter 2, Class Loaders, in Sun Java System Application Server Platform Edition 9 Developer’s Guide.
The Application Server provides these tools for assembling and verifying a module or an application:
The asant utility can help you assemble and deploy modules and applications. For details, see Chapter 3, The asant Utility, in Sun Java System Application Server Platform Edition 9 Developer’s Guide.
You can use the NetBeansTM Integrated Development Environment (IDE) to assemble Java EE applications and modules. The Platform Edition of the Application Server is bundled with the NetBeans 5.5 IDE. For more information about using the NetBeans IDE, see http://www.netbeans.org.
The verifier utility validates Java EE annotations and deployment descriptors and Application Server specific deployment descriptors against their corresponding DTD schema files. It gives errors and warnings if a module or application is not Java EE and Application Server compliant. You can verify deployment descriptors in EAR, WAR, RAR, and JAR files.
The verifier tool is not simply an XML syntax verifier. Rules and interdependencies between various elements in the deployment descriptors are verified. Where needed, user application classes are introspected to apply validation rules.
The verifier is integrated into Application Server deployment and the asant task The sun-appserv-deploy Task in Sun Java System Application Server Platform Edition 9 Developer’s Guide. You can also run it as a stand-alone utility from the command line. The verifier utility is located in the install-dir/bin directory.
You can run the verifier during Application Server deployment using the Admin Console or the asadmin deploy command with the --verify="true" option (see The asadmin Deployment Commands and The Admin Console Deployment Pages). In these cases, the output of the verifier is written to the tempdir/verifier-results/ directory, where tempdir is the temporary directory defined in the operating system. Deployment fails if any failures are reported during the verification process. The verifier also logs information about verification progress to the standard output.
For details on all the assertions tested by the verifier, see the assertions documentation provided at http://java.sun.com/j2ee/avk/index.html.
Using the verifier tool can help you avoid runtime errors that are difficult to debug.
This section covers the following topics:
The verifier tool’s syntax is as follows:
verifier [options] file
The file can be an EAR, WAR, RAR, or JAR file.
The following table shows the options for the verifier tool.
Table 1–2 Verifier Options
For example, the following command runs the verifier on the ejb.jar file with default settings:
verifier ejb.jar
The results files are ejb.jar.txt and ejb.jar.xml.
For a more complex example, the following command runs the verifier on the ejb.jar file in portability mode displaying only failures and with a timestamp:
verifier -p -rf -t ejb.jar
The results files are ejb.jartimestamp.txt and ejb.jartimestamp.xml. The format of the timestamp is yyyyMMddhhmmss.
If the verifier runs successfully and no verification errors occurred, a result code of 0 is returned. A nonzero error code is returned if errors occurred or the verifier fails to run.
You can integrate the verifier into an Ant build file as a target and use the Ant call feature to call the target each time an application or module is assembled. You can use any of the arguments described in Table 1–2. Example code for an Ant verify target is as follows:
<?xml version="1.0" encoding="iso-8859-1"?> <project name="Verifier Launcher" default="verify"> <target name="verify" description="verify using verifier script"> <exec executable="install-dir/bin/verifier" failonerror="true" vmlauncher="false"> <arg line="-d /tmp path-to-app"/> </exec> </target> </project>
Here is a sample results XML file:
<static-verification> <ejb> <failed> <test> <test-name> tests.ejb.session.TransactionTypeNullForContainerTX </test-name> <test-assertion> Session bean with bean managed transaction demarcation test </test-assertion> <test-description> For [ TheGreeter ] Error: Session Beans [ TheGreeter ] with [ Bean ] managed transaction demarcation should not have container transactions defined. </test-description> </test> </failed> </ejb> ... </static-verification>
Here is a sample results TXT file:
--------------------------- STATIC VERIFICATION RESULTS --------------------------- ---------------------------------- NUMBER OF FAILURES/WARNINGS/ERRORS ---------------------------------- # of Failures : 1 # of Warnings : 0 # of Errors : 0 ----------------------------- RESULTS FOR EJB-RELATED TESTS ----------------------------- -------------- FAILED TESTS : -------------- Test Name : tests.ejb.ejb30.BusinessIntfInheritance Test Assertion : A business interface must not extend javax.ejb.EJBObject or javax.ejb.EJBLocalObject. Please refer to EJB 3.0 Simplified API Section #3.2 for further information. Test Description : For [ sessionApp#session-ejb.jar#HelloEJB ] [ com.sun.sample.session.Hello ] extends either javax.ejb.EJBObject or javax.ejb.EJBLocalObject. ---------------------------------- END OF STATIC VERIFICATION RESULTS ----------------------------------