The below jython script attempts to modify cookies settings at enterprise application level in Websphere 7. However, I get the following exception when running it:
exception information: com.ibm.ws.scripting.ScriptingException: WASX7080E: Invalid attributes specified for type "ApplicationDeployment" -- "sessionManagement"
Here is the code:
deployedApplicationId = AdminConfig.getid('/Deployment:myWebApp/')
deployedObject = AdminConfig.showAttribute(deployedApplicationId, 'deployedObject')
overrideSessionManagAttr = ['enable', 'true']
defaultCookieAttrs = ['defaultCookieSettings', [['name', 'JSESSIONID_MY_COOKIE'], ['secure', 'true']]]
attributeList = [overrideSessionManagAttr, defaultCookieAttrs]
sessionAttributes = [['sessionManagement', attributeList]]
AdminConfig.modify(deployedObject, sessionAttributes)
AdminConfig.save()
The strange part is that when I use the create command I don't get any errors and the settings are changed accordingly.
AdminConfig.create('ApplicationConfig', deployedObject, sessionAttributes)
Can you please help identify why the error occurs when using the "modify" command?
Thank you for your time.
It looks like the modify command needs another property name to get it to work, so the script needed to be updated like this:
deployedApplicationId = AdminConfig.getid('/Deployment:myWebApp/')
smList = AdminConfig.list('SessionManager', deployedApplicationId).splitlines()
for sm in smList:
AdminConfig.modify(sm, '[ [enable true] ]')
dcs = AdminConfig.showAttribute(sm, 'defaultCookieSettings')
AdminConfig.modify(dcs, '[ [name COOKIE_NAME] [secure true] ]')
AdminConfig.save()
The fact that I needed to iterate through the smList is still no clear to me. Why did I have multiple of these records in my Websphere settings in the first place? Only the development environment has multiple records, neither UAT nor PROD have multiple records. But that's another question for another day :) .