Search code examples
webspherejythonwsadmin

WASX7017E: Jython exception File "<string>"


When i try to execute my Jython script i get this error:

WASX7017E: Exception received while running file "/opt/test_wsadmin_configura_datasource.jython"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<string>", line 29, in ?
NameError: dbuser

This is my test_wsadmin_configura_datasource.jython

##
# src: https://www.ibm.com/developerworks/community/blogs/timdp/entry/automating_application_installation_and_configuration_into_websphere_application_server46?lang=en
#
# eseguire con wsadmin.sh -lang jython

# get an environment variable
import os;
#installRoot = os.environ["INSTALL_ROOT"]

# useful variables
cell = AdminControl.getCell()
node = AdminControl.getNode()
server = AdminControl.getConfigId(AdminControl.queryNames("node="+node+",type=Server,*"))
varmap = AdminConfig.list('VariableMap', server)
appman = AdminControl.queryNames("type=ApplicationManager,*")

def createJ2CAuthAlias(alias,description,user,password):
    sec = AdminConfig.getid('/Cell:'+ cell +'/Security:/')
    alias_attr = ["alias", alias]
    desc_attr = ["description", description]
    userid_attr = ["userId", user]
    password_attr = ["password", password]
    attrs = [alias_attr, desc_attr, userid_attr, password_attr]
    authdata = AdminConfig.create('JAASAuthData', sec, attrs)
    print "J2C Auth Alias created ---> " + alias
    AdminConfig.save()
    return

createJ2CAuthAlias(dbuser,description,DBUSER,PASS)

WebSphere is running inside original docker image ibmcom/websphere-traditional:8.5.5.11-install

How can i solve?

EDIT1: Here found that the issue can be related to a non-UTF8 character.

These errors can occur because there are UTF-8 characters in the file that are not valid. 
...
An easy way to determine if a character that is not valid is causing the error is to enter export LANG=C and run the script again.

export LANG=C does not change the result.


Solution

  • Just found that double quoting arguments does the job:

    createJ2CAuthAlias("dbuser","description","DBUSER","PASS")