0

我正在尝试执行 wlst 脚本来扩展托管服务器,但出现以下错误。由于我是 python 新手,无法弄清楚问题是什么,任何指针肯定会有所帮助,谢谢

Problem invoking WLST - Traceback (innermost last):
  File "/MiddlewareOSB/MyOSB/common/bin/extendOSBDomain.py", line 214, in ?
  File "MiddlewareOSB/MyOSB/common/bin/extendOSBDomain.py", line 27, in main
  File "MiddlewareOSB/MyOSB/common/bin/extendOSBDomain.py", line 110, in createJMSResources
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'


import sys
import os

def main():
    try:
        #load properties file
        loadProperties('extend.properties')

        print('connecting ' + adminUser + ' to Admin server')
        connect(adminUser,adminPassword,'t3://'+adminHost+':'+adminPort)

        exists = 1
        index = 1

        while exists == 1:
        serverName = 'osb_server%s' % index
        print "serverName is: " + serverName
        try:
                print('Check if server exists...')
            cd('/Servers/'+serverName)
            index += 1  
        except:
            exists = 0

        managedServerName = 'osb_server%s' % index
        createManagedServer(managedServerName)
        addNewMStoClusterList(managedServerName)
        createJMSResources(managedServerName, index)
    except:
        traceback.format_exc()   
        exit()

def createManagedServer(managedServerName):
    print ('*** Creating managed server ' + managedServerName + ' ...')
    edit()  
    startEdit()
    managedServer = create(managedServerName,'Server')
    managedServer.setListenAddress(managedServerAddress)
    managedServer.setListenPort(int(managedServerPort))
    managedServer.setCluster(getMBean('/Clusters/' + clusterName))

    # To add additional properties, such as SSL, web server information, Coherence specific startup parameters,
    # server logging details or channels this would be the place to add it.
    # For instance the following (once edited) adds SSL to the server
    #
    # server.setKeyStores('CustomIdentityAndCommandLineTrust')
    # server.setCustomIdentityKeyStoreFileName(identityFileLocationAndPath)
    # server.setCustomIdentityKeyStoreType('JKS')
    # server.setCustomIdentityKeyStorePassPhrase(SSLPASSWORD)
    #
    # and this adds the coherence settings
    #
    # domainname=soaDomain+'_domain'
    # domainlocation='/usr/appl/'+'%s'%tla+'/weblogic'
    # cd('/Servers/' + managedServerName + '/ServerStart/' + managedServerName)
    # cmo.setArguments('-DOSB.coherence.localhost=' + managedServerName + ' -     DOSB.coherence.localport=7890  -DOSB.coherence.wka1=' + managedServerName + ' -DOSB.coherence.wka1.port=7890  -DOSB.coherence.wka2=' + managedServerName + ' -DOSB.coherence.wka1.port=7890 ')

    activate()
    print ('managed server created and added to the cluster')

def addNewMStoClusterList(managedServerName):
    edit()  
    startEdit() 
    cd('/Clusters/' + clusterName)
    activeCluster=cmo

    try:
        #increasing servers in list by 1
        servers = activeCluster.getNumberOfServersInClusterAddress()
        servers = servers + 1

        #adding new server address and port
        clusterList = activeCluster.getClusterAddress() + "," + managedServerAddress + ':' + managedServerPort

        #if the cluster list not empty, add the new server to the list and increase number of servers in cluster list by 1
        print ('*** Adding Server ' + managedServerName + ' to cluster address of cluster ' + clusterName + ' ...') 
        activeCluster.setNumberOfServersInClusterAddress(servers)
        activeCluster.setClusterAddress(clusterList)    

        activate()
        print ('cluster list updated')
    except:
        print('*** Cluster list failed to be updated - is the cluster address for the cluster empty?')  

def createJMSResources(managedServerName, index):
    edit()
    startEdit()
    targetServer = jarray.array([ObjectName('com.bea:Name='+ managedServerName +',Type=Server')], ObjectName)

    # creating persistance stores for jms servers
    # PLEASE NOTE - On some versions of OSB, you will need to create the physical folder for the filestore
    print ('*** Creating FileStores')

    filestore_list = ["FileStore", "WseeFileStore"]
    count = 0
    limit = 2

    while count < limit:
        filestore = filestore_list[count] + '_auto_%s' % index

        print ('*** Adding ' + filestore )

        cd('/')
        cmo.createFileStore(filestore)
        cd('/Deployments/' + filestore)
        cmo.setDirectory(filestore)
        set('Targets', targetServer)

        print ('Filestore ' + filestore + ' created')

        # create filestore directory, if it doesn't exist
        dir = System.getenv('DOMAIN_HOME') + '/' + filestore
        try:
            os.stat(dir)
        except:
            os.mkdir(dir)

        count += 1

    print ('Filestores created')

    # creating jms servers
    print ('*** Creating  JMS Servers') 

    # create wlsbJMSServer_auto_x jms server
    cd('/')
    cmo.createJMSServer('wlsbJMSServer_auto_%s' % index)
    cd('/JMSServers/wlsbJMSServer_auto_%s' % index)
    cmo.setPersistentStore(getMBean('/Deployments/FileStore_auto_%s' % index))
    set('Targets', targetServer)
    cd('/Deployments/wlsbJMSServer_auto_%s' % index) 
    cmo.setTemporaryTemplateResource('jmsResources') 
    cmo.setTemporaryTemplateName('TemporaryTmplt') 

    # create wseeJMSServer_auto_x jms server
    cd('/')
    cmo.createJMSServer('WseeJmsServer_auto_%s' % index)
    cd('/JMSServers/WseeJmsServer_auto_%s' % index)
    cmo.setPersistentStore(getMBean('/Deployments/WseeFileStore_auto_%s' % index))
    set('Targets', targetServer)

    targetWseeJmsServer = jarray.array([ObjectName('com.bea:Name=WseeJmsServer_auto_%s' % index + ',Type=JMSServer')], ObjectName)
    targetWlsbJmsServer = jarray.array([ObjectName('com.bea:Name=wlsbJMSServer_auto_%s' % index + ',Type=JMSServer')], ObjectName)

    print ('JMS Servers created')

    # creating WseeJMSModule Components
    print ('*** Create Queues: DefaultCallbackQueue-WseeJmsServer_auto_%s' % index + ' and DefaultQueue-WseeJmsServer_auto_%s' % index)

    # create subdeployment within WseeJmsModule
    cd('/JMSSystemResources/WseeJmsModule')
    cmo.createSubDeployment('WseeJmsServer_auto_%s' % index + '-Sub')

    # create DefaultQueue-WseeJmsServer_auto_x queue
    cd('/JMSSystemResources/WseeJmsModule/JMSResource/WseeJmsModule')
    cmo.createQueue('DefaultQueue-WseeJmsServer_auto_%s' % index)
    cd('/JMSSystemResources/WseeJmsModule/JMSResource/WseeJmsModule/Queues/DefaultQueue-WseeJmsServer_auto_%s' % index)
    cmo.setJNDIName('weblogic.wsee.DefaultQueue-WseeJmsServer_auto_%s' % index)
    cmo.setSubDeploymentName('WseeJmsServer_auto_%s' % index + '-Sub')
    cd('/JMSSystemResources/WseeJmsModule/SubDeployments/WseeJmsServer_auto_%s' % index + '-Sub')
    set('Targets',targetWseeJmsServer)

    # create DefaultCallbackQueue-WseeJmsServer_auto_x queue
    cd('/JMSSystemResources/WseeJmsModule/JMSResource/WseeJmsModule')
    cmo.createQueue('DefaultCallbackQueue-WseeJmsServer_auto_%s' % index)
    cd('/JMSSystemResources/WseeJmsModule/JMSResource/WseeJmsModule/Queues/DefaultCallbackQueue-WseeJmsServer_auto_%s' % index)
    cmo.setJNDIName('weblogic.wsee.DefaultCallbackQueue-WseeJmsServer_auto_%s' % index)
    cmo.setSubDeploymentName('WseeJmsServer_auto_%s' % index + '-Sub')
    cd('/JMSSystemResources/WseeJmsModule/SubDeployments/WseeJmsServer_auto_%s' % index + '-Sub')
    set('Targets',targetWseeJmsServer)

    print ('Queues within the WseeJMSModule created')

    print ('*** Creating queues within the jmsResources module')

    # create subdeployment within jmsResources
    wlsJmsServerSubName = 'wlsbJMSServer%s' % index + '_sub'
    cd('/JMSSystemResources/jmsResources')
    cmo.createSubDeployment(wlsJmsServerSubName)
    cd('SubDeployments/' + wlsJmsServerSubName)
    set('Targets',targetWlsbJmsServer)

    # create queues within jmsResources
    queue_list = ["wli.reporting.jmsprovider.queue", "wli.reporting.jmsprovider_error.queue", "wlsb.internal.transport.task.queue.email", "wlsb.internal.transport.task.queue.file", "wlsb.internal.transport.task.queue.ftp", "wlsb.internal.transport.task.queue.sftp","QueueIn"]
    count = 0
    limit = 7

    while count < limit:
        queue = queue_list[count] + '_auto_%s' % index
        dist_queue = 'dist_' + queue_list[count] + '_auto'

        print ('*** Adding ' + queue + ' to ' + dist_queue)

        cd('/JMSSystemResources/jmsResources/JMSResource/jmsResources/Queues')
        cmo.createQueue(queue)
        cd('/JMSSystemResources/jmsResources/JMSResource/jmsResources/Queues/' + queue)
        cmo.setJNDIName(queue)
        cmo.setSubDeploymentName(wlsJmsServerSubName)
        cd('/JMSSystemResources/jmsResources/JMSResource/jmsResources/DistributedQueues/' + dist_queue)
        cmo.createDistributedQueueMember(queue)
        cd('/JMSSystemResources/jmsResources/JMSResource/jmsResources/DistributedQueues/' + dist_queue + '/DistributedQueueMembers/' + queue)
        cmo.setWeight(1)

        print ('Queue created and added to UDQ')
        count += 1

    # create SAF Agent
    cd('/')
    cmo.createSAFAgent('ReliableWseeSAFAgent_auto_%s' % index)
    cd('/SAFAgents/ReliableWseeSAFAgent_auto_%s' % index)
    cmo.setStore(getMBean('/FileStores/WseeFileStore_auto_%s' % index))
    set('Targets',targetServer)
    cmo.setServiceType('Both')

    activate()
main()
4

2 回答 2

1

我看到你已经编写了很多代码,但是,它到处都是语法错误。我建议您尝试一次编写较小的块,让每个步骤在您插入时工作。

首先,您的 while 循环是无限的。

其次,如果您想在 print 中使用括号(我推荐),对于 Python 2.x,请在文件顶部使用它:

from future import print_function

第三,您应该始终使用 os.path 进行可移植文件系统路径操作。

您的错误意味着,在某处,您正在尝试使用字符串添加 None 类型。当然,这是不可能的,所以 Python 会抛出异常。您需要做的是弄清楚为什么您要添加的任何内容都没有,然后修复它;)

希望有帮助!

于 2013-06-19T08:00:02.350 回答
0

您可能需要设置环境变量DOMAIN_HOME或更改System.getenv('DOMAIN_HOME')System.getenv('DOMAIN_HOME', '.')等。

于 2013-06-19T12:28:29.233 回答