Manipulating Hawk rulebases
Facts - Tibco
Thursday, 25 August 2011 20:31

This note is for Tibco Hawk 4.8, Groovy 1.8 and JDOM version 1.1.1

I tried to generate Hawk rulebases from a template rulebase file. For example I did a search replace on certain tags in the template. In addition my groovy/ant script read the xml and added extra rules elements to the rulebase file.

The next step was creating a Monitoring Archive with the hawk mar-utility. Unfortunately this tool returned the following unspecified error:

ERROR: COM.TIBCO.hawk.config.rbengine.rulebase.RulebaseException

The first thing I saw was that the groovy xml parsers XmlParser and XmlSlurper could not correctly process CDATA tags. So I changed my script to using JDOM (version 1.1.1). Unfortunately the error did not get away.

JDOM preserves white space if you call the JDOM XMLOutputter as follows, from Groovy:

import org.jdom.output.Format
def format = Format.getRawFormat()
format.setExpandEmptyElements(true)
def xmlOutputter = new XMLOutputter(format)

Even then the error did not go away. Some CDATA sections were empty in my rulebase template. These were still cleaned up by the XMLOutputter. Calling Format.setExpandEmptyElements(boolean) did not make any difference either. After I added a space to each empty CDATA section the error disappeared.