1

我有一个调用 wsadmin 库来配置 WAS 服务器的 Jython 脚本。

我有这些功能:

def createWasObject(was_object_type, was_path, object_params):
  if isinstance(was_path, basestring):
    was_path = AdminConfig.getid(was_path)
  str_params = '['
  for k,v in object_params.items():
    str_params = str_params + '[' + k + ' "' + v + '"] '
  str_params = str_params + ']'
  return AdminConfig.create(was_object_type, was_path, str_params)

def createJdbcProviders(was_path, jdbc_providers):
  was_object_type = 'JDBCProvider'
  for jdbc_provider in jdbc_providers:
    jdbc = createWasObject(was_object_type, was_path,     jdbc_provider['params'])
    print jdbc

    for datasource in jdbc_provider['datasources']:
      ds = createWasObject('Datasource', jdbc, datasource['params'])
  print

“打印 jdbc”打印:

Teradata JDBC 提供程序(cells/jsr-websphere-1Cell01/nodes/jsr-websphere-1Node01/servers/jsr-business|resources.xml#JDBCProvider_1444648929602)"

看起来像正确的对象 ID

但是,当使用它创建数据源时,出现以下错误:

WASX7017E: Exception reçue lors de l'execution du fichier "/root/jsr_auto_deployment/jsr.py" ;异常信息:com.ibm.ws.scripting.ScriptingException:无效的对象名称:“Teradata JDBC Provider(cells/jsr-websphere-1Cell01/nodes/jsr-websphere-1Node01/servers/jsr-business|resources.xml #JDBCProvider_1444648929602)"

I am using Jython 2.7 through a Thin client. Reusing an object returned by AdminConfig.create() was working well with a Jython script ran through wsadmin.sh

4

1 回答 1

0

My problem was on that line: was_path = AdminConfig.getid(was_path)

Most of the time I was passing a string but this time I was already using an ID. So I removed the AdminConfig.getid in the function and added it in the calls when necessary only.

于 2015-10-16T09:15:19.957 回答