jython script: Mail Session attribute is set but w

2019-08-23 20:43发布

问题:

I have written Jython script to create a mail session in IBM websphere.

Jython Script :

import sys

nodeName =sys.argv[0]
serverName =sys.argv[1]

def createSession(nodeName,serverName):
     print "Creating mailsession"
     ds =AdminConfig.getid('/Node:'+nodeName+'/Server:'+serverName+'/MailProvider:Built-in Mail Provider/')
     print ds
     print AdminConfig.required('MailSession')
     name = ['name','MailSession']
     jndi = ['jndiName','mail/Session']
     host = ['mailTransportHost','mailhost.misys.global.ad']
     storehost = ['mailStoreHost','mailhost.misys.global.ad']
     mailAttrs=[name,jndi,host,storehost]
     print mailAttrs
     ss = AdminConfig.create('MailSession',ds,mailAttrs)
     AdminConfig.save()

After running the script i am able to see mail session created by script in console. but it is throwing an error on server as below :

[Root exception is javax.naming.NameNotFoundException: Context: MyServer20Cell/nodes/MyServer20Node/servers/MyServer20,
name: mail/Session: First component in name mail/Session not found. 

But the strange thing is when i opened the IBM Console and go to mail Session , without modifying any value in mail session, click on apply changes ,save it and restart the server .It Works fine and server is not throwing any error.

Can any one tell did i have done anything wrong in Script. How i can resolve this issue.

回答1:

This problem is solved. need to add this property - mailTransportProtocol and add it in attributes



标签: python jython