我正在尝试通过使用WLST运行我的python代码来创建工作管理器。在我的python代码中,尝试使用 cmo.addTarget(bean)为工作经理设置目标服务器时,它抛出以下错误:
========为WM_AgreementOps11创建WorkManager名称=======
已成功创建名称为WM_AgreementOps11的MBean类型WorkManager。
没有可用的堆栈跟踪。此异常发生在星期一 2004年2月4日13:13:51 IST。javax.management.AttributeNotFoundException: com.bea:Name = WM_AgreementOps11,SelfTuning = DefaultDomain,Type = WorkManager:SelfTuning 追溯(最近一次通话):文件 “ C:\ Oracle \ Middleware \ Oracle_Home \ wlserver \ server \ bin \ WorkManagerSetUp.py”, 主线70 cmo.addTarget(bean)java.lang.IllegalArgumentException:java.lang.IllegalArgumentException:预期为非空值
保存所有更改...成功保存所有更改。工作经理 已创建...
下面是代码:
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()