Validating deployment descriptors
Written by Joseph Ottinger
Deployment descriptors can be quite confusing, so many people cut and paste their contents. Orion is quite forgiving about the contents of the deployment descriptors, but that does not help you much. Cut and paste errors slip through easily and Orion won't tell you what you did wrong.
Ant can help you find problems in your deployment descriptors by validating the XML against the DTD. Install Ant's optional tasks and use something like the following target in your build.xml:
<target name="xml">
<xmlvalidate>
<fileset dir="." includes="**/*.xml" excludes="build.xml" />
</xmlvalidate>
<xmlvalidate>
<fileset dir="${orion.dir}/config" includes="**/*.xml" />
</xmlvalidate>
</target>
If you get errors from Ant that the xmlvalidate task is undefined, install Ant's option tasks package.
You will probably find that a few files in Orion's configuration directory do not pass validation. This problem has been reported to Orion's developers and is likely to be fixed in an upcoming release of Orion. The changes needed are trivial, so it will be a good first excercise for you. :-)
To correct the problems that Ant reports, I found it very useful to download the DTD and load it into a text editor. Remember that the order in which tags are found in XML files significant, so you'll spend quite some time swapping perfectly valid tags. Don't be alarmed when sample deployment descriptors that you find in books or on the Internet do not pass validation. Very few people use strict XML parsers.
Choosing the right DOCTYPE definition is also important. Many deployment descriptors have older DTD references, but use features from newer DTD's. This is not a problem for actually deploying the application, since Orion does not care about the DTD reference at all. Dig around for the right DTDs before removing features.
Once you have verified that all of your deployment descriptors pass strict XML validation, add the XML verification to your nightly build script. This will catch typos that slip into your CVS repository.
Copyright © 2007 IronFlare AB