Alan Burlison's Work Related Ramblings

All | General | Java | NetBeans | Perl | Solaris
« It's official - Sun... | Main | XML-based J2EE frame... »

20070405 Thursday April 05, 2007

Why I hate XML configuration files

I'm working on a reasonably large (1000+ source files) J2EE application that makes extensive (some might say utterly excessive) use of external components - it requires in the order of 50 JAR libraries to run, over and above the standard J2EE ones.

And of course many of those JAR files have their own unique XML files to configure them.

And of course many bits information related to the configuration of the application (URLs, database details etc) have to be repeated in more than one of those XML files.

And there's no global way of doing this.

So the people who originally wrote the application came up with a scheme - they'd store the configuration values in property files.

But that only helped for things that got the values dynamically, for example by using the J2SE Properties class.  All those external components they'd used didn't know anything about the application's property files, they only knew about their own unique little XML files.

So the people writing the application came up with another scheme - they'd embed tokens in all those little XML files, then use the Ant Filter task to replace them at build-time with the values from the property files.

"Job's a good 'un!" they doubtless exclaimed, flushed with their extreme cleverness.


Then I came along and had to maintain the beast, when I found:

All this means that there's a whole series of bear traps set for anyone who innocently changes any of the properties files of the application, in the mistaken assumption that the application will actually take any notice of them.

I'm sure I'm not the only person to have been hit by this problem - how to configure multiple external components which all have their own XML configuration files - without having to hand-edit each of the XML files each time every time something changes, and without hard-coding the configuration at build time.  However I'm damned if I know of a good way of doing it - although I can easily think up several not-very-good ways of doing it.

If you know, please let me know!

Posted by alanbur ( Apr 05 2007, 11:38:44 PM BST ) Permalink Comments [1]

Trackback URL: http://blogs.sun.com/alanbur/entry/why_i_hate_xml_configuration
Comments:

I am not the biggest fan of having XML configuration files myself (since they most often than not end up being a domain-specific language tacked on the side of the main system), but the application need to get configuration values somehow. Now how about this crazy idea: Create another, master XML configuration file. Use a stylesheet to transform this file into a properties file that is then run through the filter. The point of this is that the XML file can be restricted through the schema, whose lack thereof seems to be the problem with the properties file. Of course, over time this monster will evolve into a nightmare too, but maybe you are able to gain control over it just a little bit longer.

Posted by Roland Kaufmann on April 07, 2007 at 07:54 PM BST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed