|
This User's Guide describes the JavaTM Application Verification Kit (AVK) for the Enterprise and the technical recommendations behind it. This Guide covers the following topics:
IntroductionThis Guide describes what the Java AVK for the Enterprise does and how to use the tools provided as part of the kit. It also describes the features of the Sun Java System Application Server Platform Edition 8.2 ("the Application Server") that support the kit. Why Portability MattersPortability is one of the most attractive aspects of the Java programming language. Applications coded in the Java programming language can run unchanged in many different types of stand-alone or client operating environments. The Java 2 Platform, Enterprise Edition (J2EETM) extends the portability benefits of the Java language to the enterprise, providing a single set of specifications for application servers and an extensive set of compatibility tests. It allows you to run applications across different types of J2EE servers. Given the large investment most businesses have in client-server applications, the J2EE platform can save companies a lot of development time and money. With the portability features of the J2EE platform, there is little or no need to rewrite code for different servers. Whatever product you use to develop your enterprise applications, you need to ensure that your code will be easy to migrate from one application server to another. To do this, you need to make sure that your code does not use vendor-specific extensions to the J2EE platform. The Java AVK for the Enterprise is designed to help developers avoid such situations. The Java AVK for the Enterprise is designed to identify enterprise applications developed with J2EE technology that are intended to be portable across different implementations of the J2EE platform. Creating Portable Applications: Using Java BluePrintsThe Java BluePrints program provides an extensive set of guidelines, design patterns, and sample applications that serve as models for developers writing portable applications. In particular, the Java Adventure Builder Reference application showcases how to design interoperable and portable web services on the J2EE 1.4 platform, and the Java Pet Store Sample Application shows how to use the capabilities of the J2EE platform to develop robust, scalable, portable, and maintainable enterprise applications. We recommend that anyone implementing a J2EE application study these applications. See http://java.sun.com/blueprints/enterprise for information about installing the sample applications and about developing portable enterprise applications. What the Java AVK for the Enterprise DoesThe Java AVK for the Enterprise is a set of tools intended to help developers test their applications for correct use of J2EE APIs and portability across J2EE compatible application servers. The Java AVK for the Enterprise tools determine that an application suite follows the J2EE platform specification (including all the specifications for the technologies that are part of the platform) and that it runs on the Application Server. They do this in two stages:
This section covers the following topics: The Application ServerSun Java System Application Server Platform Edition 8.2 is a compatible production-grade implementation of the J2EE 1.4 specification. This product provides extensive support for web services, including the industry's most complete support for WS-I Basic Profile. Furthermore, it is also the first application server to provide integrated support for JavaServer Faces. The Application Server includes various tools to help developers prototype J2EE applications and learn about the J2EE platform and technologies. The Java AVK for the Enterprise requires an application to use the Application Server to confirm that it runs on a complete and correct implementation of the J2EE 1.4 platform. Terms UsedHere are a few terms that apply to the Java AVK for the Enterprise.
See also the J2EE Glossary at http://java.sun.com/j2ee/glossary.html. ScopeA J2EE application suite is composed of one or more deployment units, and each unit can contain one or more deployment descriptors. If the deployment unit is an EAR file, its deployment descriptor lists its components as modules; each component must also have a deployment descriptor. The deployment unit can also be a standalone module. There are four types of modules:
The Java AVK for the Enterprise performs runtime verification on only a subset of the J2EE components:
At this release, the Java AVK for the Enterprise does not perform runtime verification on the following:
CoverageGood programming practice can lead to specific code paths that are difficult or inappropriate to test. These include:
To provide flexibility to permit these reasonable cases, the Java AVK for the Enterprise sets a coverage guideline of 80% EJB method execution. The reporting tool presents coverage status based on this guideline. Different organizations may choose different internal guidelines to meet their own processes and requirements. The reporting tool provides detailed results information that will be useful. The following criteria are tracked or required by the Java AVK for the Enterprise tools:
What the Java AVK for the Enterprise IncludesTo install the Java AVK for the Enterprise 1.4.2, refer to the Installation Instructions. The Java AVK for the
Enterprise is installed in the This section describes what you get when you install the Java AVK for the Enterprise. It covers the following topics: The installation process for the Java AVK for the Enterprise automatically
installs an instrumented version of the Application Server at
Application Server Directory StructureTable 1 describes the most important directories within
Application Server ToolsThe Application Server comes with a set of tools for managing the server and
for packaging, deploying, and running J2EE applications. Many of these tools are
listed in Table 2. Most of the commands that invoke these
tools are in the
Java AVK for the Enterprise ToolsYou will use the following tools to verify your application suite:
Verifying an Application SuiteThis section describes the steps to verify an application suite using the Java AVK for the Enterprise. Here is an overview of these steps:
The following sections describe these steps in detail. Adding the Ant Tasks to your Build FileYou will find a sample <JAVKE_HOME>/samples This file also contains some sample Ant targets that you can run in order to
become familiar with the tasks before you adapt them for your own code. The code
for running the targets is also in the You can either add the necessary code to the <!DOCTYPE project [ <!ENTITY javke_targets SYSTEM "./javke_targets.xml"> ]> ... &javke_targets; The tasks you can use are defined as follows in the sample
<taskdef name="ArchiveTest"
classname="org.apache.tools.ant.taskdefs.optional.sun.verification.StaticArchive
Test"
classpath="${cpath}" />
<taskdef name="TranslateRuntimeDD"
classname="org.apache.tools.ant.taskdefs.optional.sun.verification.TranslateRuntimeDD"
classpath="${cpath}"/>
You must define the classpath to include the following:
<property name="cpath" value="${avk.home}/lib/javke-ant.jar"/>
You must also define a property named The file in the
You do not have to have the Application Server running in order to use these tasks. The following sections provide details about using the tasks. Note: The Performing Static Verification TestsThe tasks that perform the static verification tests do the following:
Static Archive TestingUse the
<target name="static-archive-test" description="static archive tests for
application containing web components, reporting on all tests">
<ArchiveTest appName="${avk.home}/samples/bookstore/bookstore.war"
reportingOpts="a" />
</target>
The
>asant static-archive-test
Buildfile: build.xml
static-archive-test:
[exec] Dec 12, 2005 6:16:46 PM APIRepository Initialize
[exec] INFO: C:\Sun\AppServer\lib\verifier\standard-apis.xml
[exec] Dec 12, 2005 6:16:47 PM com.sun.enterprise.tools.verifier.BaseVerifier preVerification
[exec] INFO: Verifying: [ bookstore ]
[exec] Dec 12, 2005 6:16:47 PM com.sun.enterprise.tools.verifier.apiscan.packaging.Archive listAllExtDirs
[exec] INFO: Extension Dir Path is C:\jdk1.5.0_05\jre\lib\ext;C:\Sun\AppServer\domains\domain1\lib\ext
[exec] Dec 12, 2005 6:16:47 PM com.sun.enterprise.tools.verifier.web.WebVerifier getClassPath
[exec] INFO: Using CLASSPATH C:\Documents and Settings\me\Local Settings\Temp\exploded20051212061646\
bookstore\WEB-INF\classes\;C:\DOCUME~1\me\LOCALS~1\Temp\.vc0.0327003
[exec] Dec 12, 2005 6:16:47 PM com.sun.enterprise.tools.verifier.tests.web.AllJSPsMustBeCompilable compile
[exec] INFO: Starting to compile JSPs with archiveUri C:\DOCUME~1\me\LOCALS~1\Temp\exploded20051212061646\bookstore
[exec] Dec 12, 2005 6:16:47 PM com.sun.enterprise.tools.verifier.tests.web.AllJSPsMustBeCompilable compile
[exec] INFO: JSPC classpath C:\Documents and Settings\me\Local Settings\Temp\exploded20051212061646\
bookstore\WEB-INF\classes\;C:\DOCUME~1\me\LOCALS~1\Temp\.vc0.0327003;C:\Sun\AppServer\lib\j2ee.jar;C:\Sun\
AppServer\lib\jaxrpc-api.jar;C:\Sun\AppServer\lib\jaxr-api.jar;C:\Sun\AppServer\lib\saaj-api.jar;C:\Sun\AppServer\
lib\mail.jar;
[exec] Dec 12, 2005 6:16:48 PM com.sun.enterprise.tools.verifier.ReportHandler writeToConsole
[exec] INFO:
[exec] # of Failures : 0
[exec] # of Warnings : 0
[exec] # of Errors : 0
[exec] Dec 12, 2005 6:16:48 PM com.sun.enterprise.tools.verifier.ReportHandler writeToConsole
[exec] INFO: Look in file "C:\Sun\javke1.4.2\reporttool\static\bookstore.war.txt" for detailed results.
[echo] See "C:\Sun\javke1.4.2\reporttool\static\verifierSummary.html" for results.
BUILD SUCCESSFUL
You can use the attributes listed in Table 3 to change the reports. For example, you could specify the following to generate reports showing only failures, on only the application client and enterprise bean components of an EAR file:
<target name="archive-test" description="static archive tests">
<ArchiveTest appName="./MyApp.ear"
reportingOpts="f"
partitionOpts="appclient,ejb" />
</target>
The summary page from the static archive tests shows the failures, warnings, passes and nonapplicable test results for each of the modules of the J2EE platform contained in the application. Each result contains a link to detailed information, including a description of the test that was run, the assertion in the specification being tested, and the name of the test. In addition, the summary includes a section that lists any errors the static archive tests encountered. If your code contains proprietary APIs, you will need to provide portable, functionally equivalent alternative code that can be executed instead of the proprietary APIs. You will need to rebuild your application using the alternative code in order to verify it. Note: For a few static archive tests, execution of the tests stops after the first failed test. Once you have corrected a failure, run the static archive test task again in order to find and correct further failures. Translating Runtime Deployment DescriptorsEvery application server has its own runtime deployment descriptors that specify implementation-specific aspects of deployment. An application that previously ran on another J2EE server must convert its runtime deployment descriptors to work with the Application Server. This process does not replace your original module or application; instead, it creates a new one with new deployment descriptors. Use the
<target name="translate-dd" description="translate runtime DD for
deployment">
<TranslateRuntimeDD
archiveName="${avk.home}/samples/weblogic_6_x/HelloWorld/HelloWorld.ear"
srcServer="weblogic6" />
Both the
If you run the
>asant translate-dd
Buildfile: build.xml
translate-dd:
[echo] Some xml files may not have translated correctly.
[java] [war] Warning: selected war files include a WEB-INF/web.xml
which will be ignored (please use webxml attribute to war task)
[java] [ear] Warning: selected ear files include a
META-INF/application.xml which will be ignored (please use appxml attribute to
ear task)
[java] BUILD SUCCESSFUL
[java] Total time: 3 seconds
[echo] See "C:\Sun\javke1.4.2\reporttool\translate\translationSummary.html"
for results.
[echo] We attempted to create an ear file even if minor errors occurred.
The application with translated deployment descriptors is in a new .ear file
located in C:\Sun\javke1.4.2\reporttool\translate\Input_Archives\asmtbuild
BUILD SUCCESSFUL
Do not use the new EAR file created by the task. Instead, open the
Note: The task also generates new standard descriptors
( Starting the Instrumented Application ServerAfter you perform static archive testing, start the Application Server with instrumentation turned on. The installation process for the Java AVK for the Enterprise modifies the server configuration files to enable instrumentation. As a result, when you start the server, instrumentation is enabled. To start the server, use the following command:
Use the asadmin start-domain --verbose domain1 For database access, you can use the Derby database that is part of the Application Server. It has a preconfigured Java Database Connectivity (JDBCTM) resource and connection pool. See the Sun Java System Application Server Platform Edition 8.2 Developer's Guide for details on using the JDBC API for database access. If your application uses a database, start the database now. Use the following command: asadmin start-database Creating Resources for the Application SuiteIf your application uses server resources, you create them administratively. For example, you can use the Admin Console or the asadmin command to create JDBC resources, Java Message Service (JMS) resources and destinations, connector resources, users and groups for security realms, and the like. To use the Admin Console, open the URL
You can use the Admin Console help system, the asadmin help command, and the J2EE 1.4 Tutorial to learn more. Specifying Runtime InformationBefore you deploy your application, you should open each module in the Application Server deployment tool and verify that the runtime information required by the Application Server is correct. Much of this information consists of the Java Naming and Directory InterfaceTM (JNDI) API names of any resources used by the application. To do this, perform the following steps:
Specific places where you need to set runtime information include the following tabs in the right-hand pane of the deploytool:
Generating Database Tables for Entity BeansFor each entity bean in your application suite, you need to generate database
tables. You may use the Derby database that comes with the Application
Server. It has a preconfigured JDBC connection pool called
If you have a database that needs to be prepopulated with data, the simplest way to this is to create an asant task. The task and the property and path settings it uses would look like this:
<property name="db.delimiter" value=";" />
<property name="db.root" value="${j2ee.home}/derby" />
<property name="db.driver" value="org.apache.derby.jdbc.ClientDriver" />
<property name="db.datasource" value="org.apache.derby.jdbc.ClientDataSource" />
<property name="db.host" value="localhost" />
<property name="db.port" value="1527" />
<property name="db.sid" value="sun-appserv-samples" />
<property name="db.url"
value="jdbc:derby://${db.host}:${db.port}/${db.sid};create=true;" />
<property name="db.user" value="APP" />
<property name="db.pwd" value="APP" />
<property name="db.jvmargs" value="-ms16m -mx32m" />
<property name="sql.script" value="YOUR SCRIPT PATH NAME HERE" />
<path id="db.classpath">
<fileset dir="${db.root}/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="create-db" depends="init"
description="Create database tables and populate database." >
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.password}"
classpathref="db.classpath"
delimiter="${db.delimiter}"
autocommit="false"
onerror="abort" >
You need to specify the SQL script that will create the database and modify the properties as needed. If your entity bean uses container-managed persistence, you can specify the resource in the deploytool and create tables as follows:
For more information on using container-managed persistence for entity beans, see the Sun Java System Application Server Platform Edition 8.2 Developer's Guide. Deploying the Application SuiteNext, deploy the application suite on the instrumented Application Server. In the deploytool, select each application or module and choose Tools->Deploy. If you are new to the Application Server, you can learn how to create, package, and deploy an application by following the instructions in the Getting Started chapter of the J2EE 1.4 Tutorial. Creating an Exclude List for Component LibrariesThe Java AVK for the Enterprise reporting tool by default processes all deployed EAR files and standalone modules, assuming that they are part of the same application suite. Normally, you should undeploy any modules that are not part of the application suite that you are verifying. Often, however, an application suite includes component libraries that are used by the application but are not part of it. Such libraries generally come from another vendor and have already been verified. You can configure the Java AVK for the Enterprise to exclude these libraries, or modules within them, from the runtime verification process. For example, suppose that vendor Wombat has developed an application named WombatApp that it wants to verify. WombatApp depends on another application, KangarooApp (a component library) in order to be functional. KangarooApp is supplied by vendor Kangaroo, which has already verified it. Vendor Wombat wants to verify only WombatApp and not KangarooApp. To exclude some or all of an application from verification, you edit the file <JAVKE_HOME>/config/appVerification/AppExcludeList.xml to indicate which application or component of the application must be excluded. Suppose that WombatApp.ear contains the following modules: ejb1.jar ejb2.jar web1.war web2.war And suppose that KangarooApp.ear contains the following modules: ejb3.jar ejb4.jar web3.war web4.war To exclude all of KangarooApp from the verification process, you would specify the following:
<exclude-list>
<j2ee-app>
<name>KangarooApp</name>
</j2ee-app>
</exclude-list>
To exclude only two components of KangarooApp, ejb3.jar and web4.war, you would specify the following:
<exclude-list>
<j2ee-app>
<name>KangarooApp</name>
<ejb-bundle>
<name>ejb3.jar</name>
</ejb-bundle>
<web-bundle>
<name>web4.war</name>
</web-bundle>
</j2ee-app>
</exclude-list>
You use the j2ee-app element to specify an application EAR file. Use the ejb-app or web-app tag to specify a standalone EJB JAR file or web WAR file. For example:
<ejb-app>
<name>EjbModule</name>
</ejb-app>
<web-app>
<name>WebModule</name>
</web-app>
For more details, you can find the DTD for for AppExcludeList.xml in the file <JAVKE_HOME>/dtds/application-verification-app-exclude_1_4.dtd. When you make entries in the AppExcludeList.xml file, do not provide a file extension for standalone module names (EAR files, EJB JAR files, or WAR files). For example, you would not provide a .ear extension for KangarooApp. (This instruction assumes that you observe the convention that the root name of the file is the name of the module. If the names are not the same, use the module name, not the root name of the file.) Provide a .jar or .war file extension for an EJB JAR or web WAR file contained within an application. After you edit AppExcludeList.xml, you can perform runtime verification on your application. The applications and components specified in the file will not be included in the verification reports. The file AppExcludeList.xml contains some fictitious entries that illustrate how to use it. You can leave these entries in the file, remove them, or comment them out. Executing the Application SuiteAfter you deploy the application suite, you must run it so as to invoke as much of its functionality as possible. In this step, you either manually or automatically invoke the JSP pages, servlets, and public EJB methods. Stopping the Instrumented J2EE ServerWhen you have finished the execution step, stop the server using the following command:
Do not undeploy the application. This command does several things as the server shuts down. First, it writes all data collected during the test execution of the application suite to disk. In addition, the server performs introspection on the deployed application suite and generates the list of J2EE public APIs (including EJB methods and web components). Running the Reporting ToolTo use the reporting tool to produce results after the run, use the following command: <JAVKE_HOME>/bin/reporttool -result This command generates HTML pages describing all relevant information found during the testing and server shutdown processes. The HTML pages are generated in the reporttool directory with the top-level page <JAVKE_HOME>/reporttool/results/suiteSummary.html. The results generated by the reporting tool are described in Interpreting the Results. To remove the results and reports generated by the instrumentation code from the <JAVKE_HOME>/reporttool/results directory, run the reporting tool with the -clear_results option: <JAVKE_HOME>/bin/reporttool -clear_results Use this option if an exception was thrown during dynamic checking and you have fixed the problem. In order to remove the exception from the results, you must clear all the results. Interpreting the ResultsThe Java AVK for the Enterprise reporting tool compares introspection and instrumentation results and produces reports from that comparison. From the comparison of the results, the reporting tool generates a set of HTML files and displays the URL of the top-level summary report. The reporting tool provides a status of Pass or Fail when summarizing the results. These numbers are based on the criteria mentioned in Coverage. The summary page of the generated reports contains pointers to the results of the static archive tests, a summary of the EJB method coverage for each module, and a summary of the web component coverage. The two kinds of coverage reports are described in the following sections: EJB Method Coverage ReportsEJB method coverage is reported by EAR file or module. The guideline is that at least 80% of the EJB methods within each module must be covered. The EJB Method Coverage page expands the EAR file or module contents and lists the JAR files and beans in each file, with the coverage. The Methods Called column shows the number of methods called versus the total number of methods for each bean. Clicking on the bean name brings up the EJB Method Coverage Detail page, which displays the status of each method within that bean. The first table contains the methods that were not called successfully. Either those methods were not called at all, or an exception was thrown during the call. The next table shows all methods that were called successfully. This information can be used to determine which methods need to be invoked to increase the coverage to meet the guidelines if the guidelines were not met. Web Component Coverage ReportsWeb component coverage is reported by context. The guideline is that 100% of the JSP pages and servlets must be called with no exceptions generated. The table on the summary page reports the percentage of the web components that were called. Clicking on either Passed or Failed brings up the Web Component Coverage page, which lists each component by the context root, whether or not it was called, and if so, whether there was an exception. This information can be used to determine which web components must be called to increase the coverage to meet the guidelines. The coverage reports do not list JSP pages that are included by other JSP pages using an include directive. Instead, the reports list only the JSP pages that contain the include directives for these pages. JSP pages included with an include action, however, are listed in the coverage reports. How the Tools Produce ResultsThis section describes how the tools collect dynamic data and generate metrics using two primary mechanisms: introspection and instrumentation. It covers the following topics: IntrospectionThe introspection process generates the list of required EJB methods to be invoked. The list contains all public methods in the bean's remote and local interfaces, the onMessage method for message-driven beans, and all create methods for session and entity beans. It excludes the methods that are on the Exclude List (the file <JAVKE_HOME>/config/appVerification/ExcludeList.xml, not to be confused with AppExcludeList.xml). A list of excluded methods is provided as input to the introspection process, and in addition, other methods are excluded when the tool is dynamically generating the final required list. For example, all CMP and CMR fields supporting set and get methods are excluded from the final list, and all remove methods, finder methods, and the create methods for message-driven beans are excluded as well. The list of required web components contains all servlets and JSP pages that have entries in the web.xml file and all files ending with .jsp. This combination of the EJB and web component lists is the master list that determines which EJB methods and web components must be called. This information is used in calculating the percentage numbers. InstrumentationThe instrumented Application Server has been modified to log all invocations during execution. For EJB components, that means all invocations of public business methods, of the ejbCreate method for session and entity beans, and of the ejbRemove method. In addition, the server records any system exceptions that were thrown while a method was executed. Each web component that is invoked is also recorded. The combination of these two lists is the total list of invoked entities. This total list is used when comparing against what was generated from introspection. Additional NotesEach time the reporting tool runs, it compares the instrumentation and introspection results and produces the results. You may start the server again and call additional J2EE public API methods. Instrumentation results from this run will be merged with existing instrumentation results. Introspection is run each time the Application Server is shut down. This increases the time required to shut down the server. Obtaining Support for the Java AVK for the EnterpriseTechnical support from Sun is available. For details, go to the Java AVK for the Enterprise web page: http://java.sun.com/j2ee/verified/avk_enterprise.html Further InformationFor more information about the Java programming language, the J2EE platform, and portability, refer to the following:
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||