Saturday, January 7, 2012

Fix for bug in method createUsingTemplate()

Here is a fix for a recently-discovered problem which has been hiding in wsadminlib for a long time.

Method createUsingTemplate() calls helper method _create() and passes-in a template.  When the template parameter is non-null, _create() calls AdminConfig.create() with the additional template parameter.  This doesn't work.  It should be calling AdminConfig.createUsingTemplate().

To fix it, edit your copy of wsadminlib, go to helper method _create() and find the section 'if template' (around line 8676, depending on your version).  Change AdminConfig.create() to AdminConfig.createUsingTemplate().  It should look like this:

        if template:
            sop(m, 'AdminConfig.create(%s, %s, %s, %s)' % (repr(type), repr(parent), repr(attrs), repr(template)))
            object=AdminConfig.createUsingTemplate(type, parent, attrs, template)

Many thanks to Yun-Shian Jiang in Canada who reported the problem, debugged it, and suggested the correct fix.