The Source for Java Technology Collaboration
User: Password:
Register | Login help    

Search

Online Books:
java.net on MarkMail:


Verification Tools for Migration to GlassFish

Posted by sekhar on September 23, 2008 at 6:29 PM PDT

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 GlassFish 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 Sahoo for his input on this topic.

GlassFish Verifier

The GlassFish verifier tool is part of the GlassFish distribution and can be found in the <gf-install>/bin 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).

nbpackage-screen1.jpg

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.

nbpackage-screen2.jpg

The NetBeans GUI provides the same options as (verifier.bat --gui ).

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 task.

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.

  
       <target name="all">
         <!-- verifiy the bean ear -->
           <exec executable="cmd">
             <arg value="/c"/>
             <arg value="verifier.bat"/>
             <arg value="${bean.ear.name}"/>
         </exec>
       </target>

Admin Console

You can also verify the archive at deployment time by enabling the Run Verifier check box.

admin-verify.jpg

Java AVK

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.

Summary

For most of my migration examples (at least so far) I have found the GlassFish verfier to be useful and easiest to use.

Related Topics >> Glassfish      
Comments
Comments are listed in date ascending order (oldest first)

Hi Sekhar, Nice post! I've seen people use the verifier to store the results in their VCS tree so that they are able to understand where non-portable code came from and when. Of course you could also catch the issue earlier with a continuous build. Also, the verifier tool bundled in GlassFish has flags to let you check for either subsets of the the app (says EJB3's only) or for a level of API: J2EE 1.4 or Java EE 5. Thought I'd mention that. cheers, -Alexis

nice tool.. AFAIK: the most wanted tool is a conversor between the deployment and persistence descriptors of JBoss and Glassfish.. since both containers are using XML as deployment descriptor, I suppose it shouldn't be that hard to create a XSLT or other transformer that receive persistence.xml and deployment descriptor from one side the publish the equivalent to the other one... JBoss: Hibernate Glassfish: Toplink and, of course, to adapt the deployment descriptors, detecting proprietary extensions, etc..

Hi Alexis. Yes. There are other GlassFish flags which can be obtained by verifier --help option. I was emphasizing the non obvious aspects. The option for a level of API: J2EE 1.4 or Java EE 5 is not listed in the verifier.bat --help command. So it looks like it is undocumented. I am assuming you are referring to the -m option. If one uses always uses the verifier which is part of the GlassFish distribution, then this option is not of much value in migration.

Hi felipegaucho . The Migration Tool for Glassfish on https://migrate2glassfish.dev.java.net/ performs the conversions of deployment descriptors (and some more). You can see which versions of the servers are supported on the above site. Migration Tool does not handle the translation of persistence.xml.