2012-07-06 55 views
3

我試圖通過WLST執行遠程上傳和部署。 我成功部署了已存在於WebLogic服務器路徑中的應用程序。但現在,我想部署一個遠程可用的。使用WLST進行遠程上傳

是否有在部署WebLogic服務器之前通過WLST上傳WAR/EAR的任何可能性?

我正在運行weblogic 12C。

我試着用:

java -cp wlserver/server/lib/weblogic.jar weblogic.Deployer -adminurl t3://WeblogicServer:7001 -user weblogic -password weblogic -deploy /tmp/HelloWorld.war -remote -upload 

給我作爲返回:

weblogic.Deployer invoked with options: -adminurl t3://WeblogicServer:7001 -user weblogic -deploy /tmp/HelloWorld.war -remote -upload 
<6 juil. 2012 17 h 58 CEST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, HelloWorld [archive: /tmp/HelloWorld.war], to configured targets.> 
[J2EE Deployment SPI:260080]Unable to define the application install directory at "/tmp/helloworld.war". Directory could not be created or is a file. 

當我在服務器上檢查,沒有什麼部署。

回答

4

我找到了解決辦法: 我們不能使用/ tmp目錄作爲源,因爲weblogic.Deployer使用這個目錄。

所以命令是:

java -cp wlserver/server/lib/weblogic.jar weblogic.Deployer -adminurl 
t3://WeblogicServer:7001 -user weblogic -password weblogic -deploy 
/home/admin/HelloWorld.war -remote -upload 
2

是的,有。看看WLST deploy command reference(此鏈接適用於版本10gR3)。
您可以使用true指定remoteupload選項,因爲它們的默認值爲false。

PS 1:remote選項不可用在WebLogic 9.0及以上版本(但你總是可以得到一個新的weblogic.jar,並嘗試
PS 2:你需要有到管理界面遠程訪問(通常端口。7001和/或7002),這意味着打開防火牆等
PS 3:請提供您的WebLogic服務器的版本,因爲這可能會幫助我們來幫助你

+0

我已更新我的帖子。 – Lite 2012-07-06 20:13:08

+0

從未見過這樣的錯誤。如果我找到了一些東西,請看看並告訴你。 – Viccari 2012-07-06 20:24:06

+0

好的我正在嘗試 – Lite 2012-07-09 06:51:35

0

寫我自己,能做到取消部署+部署。部署行是:

部署(項目,存檔 ,apptargets, '舞臺',計劃 ,遠程= '真',上傳= '真',archiveVersion = archiveversion,planVersion = planversion)

在部署使用的版本號的
  • 缺點是與計劃工作不
  • 重新部署

完整的腳本:(線旁碼出自己,我不得不添加一些空格來放置它在這裏)

from java.io import FileReader 
from datetime import datetime 


def deployApp(project, archive, archiveversion, plan, planversion, apptargets): 

#### UNDEPLOY app   
try: 

    domainConfig() 
    cd('/') 
    found = false 
    for app in cmo.getAppDeployments(): 
     name=app.getName() 

     try:     
      cd('/AppDeployments/' + name) 
      applicationName=get('ApplicationName') 

      if applicationName==project: 
       print '\n__ FOUND aplication: ', name 
       found = true 

       version=get('VersionIdentifier') 
       sourcePath=get('SourcePath') 
       planPath=get('PlanPath') 

       targets='' 
       for target in cmo.getTargets(): 

        targetName=target.getName() 
        if targets=='': 
         targets=targetName 
        else: 
         targets=targets + ', ' + targetName 

       print ' applicationName:\t', applicationName 
       print ' version:\t\t', version 
       print ' sourcePath:\t', sourcePath 
       print ' planPath:\t', planPath 
       print ' targets:\t\t', targets 

       if version==archiveversion + '#' + planversion: 
        print '\nCorrect Application version found. No installation needed\n' 
        return 
       else: 
        print '\n__ REMOVING application: ',applicationName, '  version:', version 
        undeploy(project) 

     except:  
      print "IGNORE ERROR: (deployed applicaties gegevens ophalen) ", sys.exc_info()[0] 

    if found==false: 
     print "Application " + project + "not found." 

except:  
    print "Failure in application remove part: ", sys.exc_info()[0] 
    raise 


# get deploy targets 
try: 
    if apptargets==None: 
     serverConfig() 
     cd('/') 
     targetList = []    
     for cluster in cmo.getClusters(): 
      targetList.append(cluster.getName()) 
     apptargets = ",".join(targetList) 

     print 'USING default app target:', apptargets, " (apptargets not found in environmentfile)" 
except: 
    print "Failure while creating default target", sys.exc_info()[0] 
    raise 


#### DEPLOY app 
try:   
    print '\n__ DEPLOYING application: ', project, archiveversion + '#' + planversion + ' target:' + apptargets 

    deploy(project, archive 
    , apptargets, 'stage', plan 
    , remote='true', upload='true', archiveVersion=archiveversion, planVersion=planversion) 
except:  
    print "Failure in deployment part: ", sys.exc_info()[0] 
    raise 


# connect to domein 
# 1) in plain passsword 
# 1) using encrypted domain credential in separate files 
# 2) using encrypted domain credential in home directory user 
def Connect(domainproperties): 
plainUser = domainproperties.getProperty("user") 
plainPassword = domainproperties.getProperty("password") 
if not (plainUser is None) and not (plainPassword is None): 
    print "Connecting with user & password" 
    connect(plainUser, plainPassword, domainproperties.getProperty("url")) 
    return   

encryptedUserConfigFile = domainproperties.getProperty("encryptedCredentialsFile") 
encryptionKeyFile = domainproperties.getProperty("encryptionKeyFile")  
if not (encryptedUserConfigFile is None) and not (encryptionKeyFile is None): 
    print "Connecting with encryptedCredentialsFile: ", encryptedUserConfigFile, " and encryptionKeyFile: ", encryptionKeyFile 
    connect(userConfigFile=encryptedUserConfigFile, userKeyFile=encryptionKeyFile, url=domainproperties.getProperty("url")) 
    return 

print "Connecting with encryptedCredentialsFile in home directory" 
connect(url=domainproperties.getProperty("url")) 
return  



try: 
print "____ running app_deploy.py at " + str(datetime.now()) 

project = sys.argv[1] 
archive = sys.argv[3] 
archiveversion = sys.argv[4] 
plan = sys.argv[5] 
planversion = sys.argv[6]  
environmentfile = sys.argv[2] 

propertyfilereader=FileReader(environmentfile) 
domainproperties=Properties() 
domainproperties.load(propertyfilereader) 

print " environment: ", environmentfile 
print " Ear: ", archive, " version:", archiveversion 
print " plan: ", plan, " version:", planversion 

## Connect 
#connect(domainproperties.getProperty("user"), domainproperties.getProperty("password"), domainproperties.getProperty("url")) 
Connect(domainproperties) 

try: 

    ## Deploy 
    deployApp(project, archive, archiveversion, plan, planversion, domainproperties.getProperty("apptargets")) 

finally: 
    # niet dat het uitmaakt, maar wel zo netjes 
    disconnect() 

except: 
print "ABORT APP DEPLOY: ", # sys.exc_info()[0], "_", sys.exc_info()[1] 
raise 

玩得開心。