我正在尝试通过使用 WLST 运行我的 python 代码来创建一个工作管理器。在我的 python 代码中,当尝试使用cmo.addTarget(bean)为工作管理器设置目标服务器时,它会引发以下错误:
======= 为 WM_AgreementOps11 创建 WorkManager 名称 =======
已成功创建名为 WM_AgreementOps11 的 MBean 类型 WorkManager。
没有可用的堆栈跟踪。此异常发生在 IST 2019 年 2 月 4 日星期一 13:13:51。javax.management.AttributeNotFoundException: com.bea:Name=WM_AgreementOps11,SelfTuning=DefaultDomain,Type=WorkManager:SelfTuning Traceback(最近一次调用最后):文件“C: \Oracle\Middleware\Oracle_Home\wlserver\server\bin\WorkManagerSetUp.py",第 70 行,在 main cmo.addTarget(bean) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: A non-null value expected
保存所有更改... 成功保存所有更改。WorkManager 已创建...
下面是代码:
import sys
import os
import jarray
import dircache
import traceback
from java.io import File
from java.io import FileInputStream
from java.lang import String
#=======================================================================================
myPropertyFile = "workManagerProperties.properties"
print '======= Reading Property File and Connecting to Server ========'
propInputStream = FileInputStream(myPropertyFile)
configProps = Properties()
configProps.load(propInputStream)
#=======================================================================================
# connection() Definition
#=======================================================================================
def connection():
print '===> Connecting as '+ username + ' To WebLogic URL ' + url + '...'
try:
connect(configProps.get("username"), configProps.get("password"), url)
except WLSTException:
print '==> Error Connecting to The URL ' + url
CancelEdit('y')
exit()
print '==== Exiting Because Of Connectivity Error ===='
#===== THE SERVER URL ==================================================================
url=configProps.get("protocol") + '://' + configProps.get("host") + ':' + configProps.get("AdminPort")
connection()
#=======================================================================================
wmcount=configProps.get("workManager.count")
print '======= Number of Work Managers to be set: ' + wmcount + ' ======='
#=======================================================================================
# START EDITING WORK MANAGER
#=======================================================================================
def main():
print ('================== inside main ==================')
DSCOUNT=1
#=======================================================================================
while(DSCOUNT<=int(wmcount)):
edit()
startEdit()
ServerName=configProps.get("ServerName")
domainName=configProps.get("domainName")
workManagerName=configProps.get("workManagerName."+str(DSCOUNT))
MaxThread=configProps.get("MaxThread."+str(DSCOUNT))
MinThread=configProps.get("MinThread."+str(DSCOUNT))
maxThreadConstraintName=configProps.get("maxThreadConstraintName."+str(DSCOUNT))
minThreadConstraintName=configProps.get("minThreadConstraintName."+str(DSCOUNT))
#==================================== WORK MANAGER ========================================
print '======= Target Server for Work Managers: ' + ServerName + ' ======='
print '======= Creating a WorkManager name for ' + workManagerName + ' ======='
cd('edit:/SelfTuning/' + domainName + '/WorkManagers/')
try:
create(workManagerName,'WorkManagers')
except:
traceback.print_exc()
cd('edit:/SelfTuning/' + domainName + '/WorkManagers/' + workManagerName)
bean = getMBean("/Servers/"+ ServerName)
try:
cmo.addTarget(bean)
except:
traceback.print_exc()
save()
print ' WorkManager Created...'
print '======= Creating MaxThreadsConstraint ======='
cd('edit:/SelfTuning/' + domainName + '/MaxThreadsConstraints/')
try:
create(maxThreadConstraintName,'MaxThreadsConstraints')
except Exception:
print 'Issue in Creating MaxThreads exiting'
cd('edit:/SelfTuning/' + domainName + '/MaxThreadsConstraints/' + maxThreadConstraintName)
bean = getMBean("/Servers/"+ ServerName)
try:
cmo.addTarget(bean)
except:
traceback.print_exc()
set('Count',MaxThread)
save()
print ' MaxThreadsConstraints Created...'
print '======= Creating MinThreadsConstraint ======='
cd('edit:/SelfTuning/' + domainName + '/MinThreadsConstraints/')
try:
create(minThreadConstraintName,'MinThreadsConstraints')
except Exception:
print 'Issue In Creating MinThreads '
cd('edit:/SelfTuning/' + domainName + '/MinThreadsConstraints/' + minThreadConstraintName)
bean = getMBean("/Servers/"+ ServerName)
try:
cmo.addTarget(bean)
except:
traceback.print_exc()
set('Count',MinThread)
save()
print ' MinThreadsConstraints Created...'
print '======= Assigning the MaxThreadConstraint to the WorkManager ======='
cd('edit:/SelfTuning/' + domainName + '/WorkManagers/' + workManagerName)
bean=getMBean('/SelfTuning/' + domainName + '/MaxThreadsConstraints/' + maxThreadConstraintName)
cmo.setMaxThreadsConstraint(bean)
print '======= Assigning the MinThreadConstraint to the WorkManager ======='
cd('edit:/SelfTuning/' + domainName + '/WorkManagers/' + workManagerName)
bean=getMBean('/SelfTuning/' + domainName + '/MinThreadsConstraints/' + minThreadConstraintName)
cmo.setMinThreadsConstraint(bean)
save()
activate(block="true")
print '==> WorkManager Creation Finished ... Please Double Check from AdminConsole...'
DSCOUNT=DSCOUNT+1
disconnect()
main()