Validate Configuration
against Build Artifacts:
An Essential Step for your Build Process

by
Harold Fortuin, Ph.D., Principal Software Engineer
Fortuitous Consulting Services, Inc.

Download this tool and its example JavaEE WAR from this site


For some time now, any moderately complex JavaEE project is put together for build and deployment using Java-based tools such as Ant and Maven. And typically these projects include a number of configuration files, not just those needed by the build tool.
These are demanded by commonly used frameworks such as Hibernate for data access, the various Spring libraries,
JavaEE servlets and Java Server Pages (JSPs).
And each of these frameworks in turn has its own configuration files which include fully qualified names of Java classes specific to your project.

Typical JavaEE build processes include the following steps:

Then the following steps occur after deployment: before exposing the application to internal and/or external customers.

Of course, the step of launching the application server can take plenty of time - easily involving many minutes. Therefore, developers, testers, and
DevOps personnel need to catch errors in the build and/or deployment as early as possible -
to avoid multiple relaunches.

Unfortunately, I have noted a missing step in the build processes at various clients over the years - one that has led to such
multiple application server reboots. The issue?...

NO test or process is executed to ensure that Java class files referenced in configuration files are ACTUALLY PRESENT, either in the build directories
or containing build archives! Anyone who has ever made a spelling error or misnamed a file can confirm how easily this can happen!

Fortunately, this oversight is not that hard to address. My Java tool Validate Configuration Against Build can integrate easily with existing build tools
like Ant and Maven, and will provide a useful start to others wishing to validate their own build configurations. This 1.0 implemention
tests for the presence of class files in build directories referenced from XML files, and can be configured by QA, DevOps, or engineering personnel. It is configured to validate these relationships for the example..

The example WeatherDataApp, also a sister project on Github, is a JavaEE Servlet 4.0/JSP/HTML 5 web application that calls a US National Weather Service RESTful XML web service to return up to 7 days of forecast high and low temperatures starting from tomorrow, for some user-selected locations in the USA. By running this validation tool prior to packaging class files into build archives such as JARs, WARs, or EARs, one can reduce the likelihood of a runtime error when starting your JavaEE or Java process.

The presentation is available from NEJUG here and source code, executable Java jar, example WeatherDataApp, and its configuration files
plus validateConfigurationAgainstJsps are freely available from Github