Search code examples
webspherejythonwsadmin

WASX7129E: Cannot create objects of type "Property" in parents of type "DescriptiveProperty"


I am using wasdmin shell and jython lang for setting properties in WAS9. Actually I have created an automated process with several shell and jython scripts which helps my application setup. While using AdminConfig.create(), it throws below exception for few properties:

[1/17/19 17:06:20:032 CET] 00000001 AbstractShell E WASX7120E: Diagnostic information from exception with text "com.ibm.ws.scripting.ScriptingException: WASX7129E: Cannot create objects of type "Property" in parents of type "DescriptiveProperty" " follows:

com.ibm.ws.scripting.ScriptingException: WASX7129E: Cannot create objects of type "Property" in parents of type "DescriptiveProperty"

My code first checks if property is already existing or not, if it exists the I delete it and create it, this idea I received after looking into IBM's jython file for adding JVM properties. This is the current flow of my code. Earlier I used to check if property already exists or not, if it exists the I used to modify it else create it. I was getting other error from modify block that is why I am using delete then create logic now.

currentProps = getListArray(AdminConfig.list(property, parent))
for prop in currentProps:
    if property == AdminConfig.showAttribute(prop, "name"):
        logging.info('Removing existing property from Server')
        AdminConfig.remove(prop)

# create new property
logging.info('Creating new property %s', key)
if type:
    AdminConfig.create(
        property,
        parent,
        [
            [ 'type',  type ],
            [ 'name',  key ],
            [ 'value', value ],
        ]
    )
else:
    AdminConfig.create(
        property,
        parent,
        [
            [ 'name',  key ],
            [ 'value', value ],
        ]
    )

I am willing to know if it is possible to judge which property is descriptive, so I can use an if else block to divert.


Solution

  • The error occurred is correct, it has to be handled by checking the type of parent's property. If it is other than property, then I am using AdminConfig.modify() and if it is of type property, then AdminConfig.remove() and AdminConfig.create().

    if('#DescriptiveProperty_' in parent) or ('#StreamRedirect_' in parent):
      AdminConfig.modify(parent,[[ key, value ]]
    

    This solves the problem and no more errors like: com.ibm.ws.scripting.ScriptingException: WASX7129E: Cannot create objects of type "Property" in parents of type "DescriptiveProperty"