Verification Tools for Migration to GlassFish
When migrating a Java EE/J2EE application to glassfish, often
the first step is to determine if the application is using non
portable Java EE/J2EE application features. In my previous
migration blogs, I demonstrated the use of the GlassFish
verifier tool for this purpose. However, there are other tools
that can also be used to verify the portability of a Java
EE/J2EE application - NetBeans Package Archiver, Java AVK,
Admin Console. I will highlight the verification support in
these tools in the context of migrating applications to
GlassFish . Thanks for my collegue href="http://weblogs.java.net/blog/ss141213/">Sahoo
for his input on this topic.
The GlassFish verifier tool is part of the GlassFish
distribution and can be found in the
directory. The verifier tool validates Java EE
annotations, standard Java EE deployment descriptors and
GlassFish server specific deployment descriptors of a Java EE
application or module against the corresponding DTD or schema
files. The validation performed are listed in the
Assertion list .
A validation failure will generate an error or a
warning. Thus, the verifier, which can flag non compliant
aspects of a Java EE application or module, is a useful tool
when migrating from other application servers to GlassFish.
The verifier tool can be run from the command line and
supports several options. One of the options specifies the
mode in which the verifier tool can be run.
- verifier.bat --portability archive-file (portability mode)
- verifier.bat archive-file (appserver mode)
The archive-file can be a EAR, WAR, RAR, and JAR file.
When the --portability swtich is specified, application is
verified for Java EE compliance. When the --portability
switch is omitted (appserver mode), the verifier tool
performs additional checks on the correct usage of GlassFish
application server features. The default is appserver
mode. When migrating Java EE applications from other
application servers, since we are concerned mostly with the
use of verifier for detecting API extensions, the use of
--portability switch is the most useful.
Another command line option is the -u | --gui option that
can be used to run the verifier tool using a GUI. This option
works but it is deprecated. A Warning message pops up when
this option is used. Note that NetBeans "Packaged Archive"
project supports this same functionality.
NetBeans Packaged Archive project
NetBeans "Packaged Archive" project allows one to open an
archive, edit deployment descriptors, assemble and deploy the
application on a Java EE server. It also supports a
verification of the archive. The verification done is in the
appserver mode. To verify using the Packaged Archive project,
Create the Archive project (specifying the archive being migrated).
Verify the archive. The following example shows a screen shot
of an attempt to verify an WebSphere sample application,
Plants. I generated the ear file by exporting the Plants
application from within the WebSphere Admin console.
The NetBeans GUI provides the same options as (verifier.bat
The NetBeans Package Archive project and the verifier tool
are useful for verification at development time. However, it
is possible to verify application at deployment time using
ant scripts or the Admin Console.
Ant Task Integration
Ant provided with GlassFish application server contains server
specific tasks for developing, deploying and undeploying Java
EE modules and applications. These are described in GlassFish
Developer's guide. One such ant task is the sun-appserv-deploy
task that can be used for deployment. An application can be
verified at deployment time using the "verify" attribute:
The verification is done in the appserver mode. There is no
way to specify the --portability switch when using the ant
There is currently no ant task integrating verifier to be used
at development time. However, you can use the ant exec task to
invoke the verifier. For e.g.
<!-- verifiy the bean ear -->
You can also verify the archive at deployment time by enabling
the Run Verifier check box.
Java AVK for Enterprise
is a tool kit that can help with testing of portability of Java
EE/J2EE application across different Java EE/J2EE application
servers. Java AVK for Enterprise can perform both static
verification and dynamic verification. From the point of view of
testing portability of applications for migration, static
verification is the most useful.
At installation time, Java AVK for Enterprise prompts the user
to select either the Appserver bundled with the AVK or use an
an Application server already installed. The Application Server
must be 9 Platform Edition. As a result, GlassFish or SJSAS
bundles installed separately cannot be used with Java AVK for
Enterprise. Java AVK installation will fail with "Not a valid
Application Server version. This is one of the reasons why I
find it easier to use the GlassFish verifier rather than Java EE
AVK in my migration examples. i.e. I prefer or have to use an
existing GlassFish version (GlassFish, SJSAS 9.X, GlassFish +
MySql bundle) which may not work with the Java AVK for Enterprise.
Java AVK for Enterprise does support a ArchiveTest ant task,
which provides limited control over a few of the options.
For most of my migration examples (at least so far) I have
found the GlassFish verfier to be useful and easiest to use.