<bea-050001> WLContext.close()在与创建它的线程不同的线程中调用</bea-050001>

时间:2014-02-20 06:06:34

标签: python weblogic wlst

我已经编写了wlst脚本来递归地实现以下任务

  • 停止申请
  • 取消部署应用程序
  • 部署应用程序

当我执行脚本时,取消部署或部署只发生在1个应用程序中。对于其他应用程序,它失败并显示以下错误消息。您能帮助我解决问题吗?

File "<iostream>", line 1116, in domainConfig
  File "<iostream>", line 1848, in raiseWLSTException
WLSTException: Error cding to the MBean
<Feb 20, 2014 11:28:44 AM IST> <Warning> <JNDI> <BEA-050001> <WLContext.close() was called in a different thread than the one in which it was created.>

WLST脚本我写的是什么

import sys
import os
import getopt
#========================
#Usage Section
#========================
def usage():
    print "Usage:"
    print "java weblogic.WLST manageApplication.py -u username -p password -a adminUrl [<hostname>:<port>] -t deploymentTarget\n"
    print "java weblogic.WLST manageApplication.py -u weblogic -p weblogic1 -a t3://localhost:7001 -t AdminServer\n"
    sys.exit(2)
#========================
#Connect To Domain
#========================
def connectToDomain():
    try:
        connect('weblogic','weblogic1','t3://localhost:7001')
        print 'Successfully connected to the domain\n'
    except:
        print 'The domain is unreacheable. Please try again\n'
        exit()
#========================
#Application undeployment Section
#========================

def undeployApplication():
    cd ('AppDeployments')
    myapps=cmo.getAppDeployments()
    for appName in myapps:
        domainConfig()
        cd ('/AppDeployments/'+appName.getName()+'/Targets')
        mytargets = ls(returnMap='true')
        domainRuntime()
        cd('AppRuntimeStateRuntime')
        cd('AppRuntimeStateRuntime')
        for targetinst in mytargets:
            curstate4=cmo.getCurrentState(appName.getName(),targetinst)
            print '-----------', curstate4, '-----------', appName.getName()
            deploymentName=appName.getName()
            deploymentTarget=targetinst
            print deploymentName
            print deploymentTarget
            stopApplication(deploymentName, targets=deploymentTarget)
            undeploy(deploymentName, targets=deploymentTarget)

#========================
#Input Values Validation Section
#========================

if __name__=='__main__' or __name__== 'main':
    try:
        opts, args = getopt.getopt(sys.argv[1:], "u:p:a:t:", ["username=", "password=", "adminUrl=", "deploymentTarget="])
    except getopt.GetoptError, err:
            print str(err)

username = ''
password = ''
adminUrl = ''
deploymentTarget = ''

for opt, arg in opts:
    if opt == "-u":
        username = arg
    elif opt == "-p":
        password = arg
    elif opt == "-a":
        adminUrl = arg
    elif opt == "-t":
        deploymentTarget = arg

if username == "":
    print "Missing \"-u username\" parameter.\n"
    usage()
elif password == "":
    print "Missing \"-p password\" parameter.\n"
    usage()
elif adminUrl == "":
    print "Missing \"-a adminUrl\" parameter.\n"
    usage()
elif deploymentTarget == "":
    print "Missing \"-c deploymentTarget\" parameter.\n"
    usage()
#========================
#Main Control Block For Operations
#========================

def deployMain():
    for line in open("c:\\wlst\\applicationsList.txt"):
        temp_line = line
        fields = temp_line.strip().split(",")
        print(fields[0]+" "+fields[1])
        deploymentName = fields[0]
        deploymentFile = fields[1]
        print deploymentName+" "+deploymentFile+" "+deploymentTarget+"/n"
        deploy(deploymentName,deploymentFile,targets=deploymentTarget)        
#==================
#main block
#=====================    
connectToDomain()
undeployApplication()
deployMain()
disconnect()

1 个答案:

答案 0 :(得分:1)

WLContext.close()可能不是真正的问题(甚至在某些Oracle示例中也是如此)。在调用部署和取消部署时,您会看到哪些错误消息?

您应该看到类似的内容:

Deploying application from /tmp/something/myapp.ear
Current Status of your Deployment:
Deployment command type: deploy
Deployment State       : completed
Deployment Message     : no message

我也看到你从不在脚本的最后调用activate(),这样如果你在生产模式下运行就可能出现问题。

尝试在deployMain()之后在脚本的最后添加以下内容:

save()
status = activate(300000, "block='true'")
status.getStatusByServer()
status.getDetails()

<强>更新

发生激活错误是因为在取消部署之前没有调用edit():

# Get edit/lock for upcoming changes
edit()
startEdit(120000, 120000, 'false')
undeployApplication()

我认为你会更好地简化你的取消部署。您不需要经历确定目标的复杂性,因为您已经从所有目标取消部署。试试这个,看看你是否可以取得进展:

cd ('AppDeployments')
myapps=cmo.getAppDeployments()
for appName in myapps:
   try:
      appPath = "/AppDeployments/" + appName.getName()
      cd(appPath)
      print "Stopping deployment " + appName.getName()
      stopApplication(appName.getName())
      print "Undeploying " + appName.getName()
      undeploy(appName.getName(), timeout=60000)
   except Exception , e:
      print "Deployment " + appName.getName() + " removal failed."