开发者

Determine if EAR Has Been Deployed in WebLogic Server Using WLST?

I am trying to create a simple python script that deploys my EAR file to the AdminServer of Weblogic. I have searched the internet and the documentation provided by Oracle, but I cannot find a way to determine if the application has been previously deployed. I would like my script to check if it has been, and if so, issue a redeploy command. If not, issue a deploy command.

I have tried to modify example scripts I've found, and although they've worked, they are not behaving as intended. One of the things I was trying to do was check (using the cd command) if my EAR was in the deployments folder of WebLogic and if it was, issue the redeploy. If not, it should throw an Exception, where I would issue the deploy. However, an Exception is thrown everytime when I issue the cd command in my script:

try:
    print 'Checking for the existence of the ' + applicationName + ' application.....'
    cd('C:\\Oracle\\Middleware\\user_projects\\domains\\base_domain\\config\\deployments\\MyTestEAR.ear\\')
    print 'Redeploying....'
    #Commands to redeploy....

except WLSTException:
    #Commands to deploy

I'm running this script on Windows using execfile开发者_JAVA百科("C:\MyTestDeployer.py") command after setting my environment variables using the WLST Scripting Tool. Any ideas? I've also tried to use a different path in my cd command, but to no avail. Any ideas?


It works for me:

print 'stopping and undeploying ...'

try:
    stopApplication('WebApplication')
    undeploy('WebApplication')
    print 'Redeploying...'

except Exception:
    print 'Deploy...'

deploy('WebApplication', '/home/saeed/project/test/WebApplication/dist/WebApplication.war')
startApplication('WebApplication2')


I've done something like that in the past, but with a different approach...

I've used the weblogic.Deployer interface with the -listapps option to list the apps/libraries deployed to the domain, which I would then compare to the the display-name element of application.xml generated in the archive

The problem I've found using plain file-names, in my case, was that archives came with the date in which they were generated. Which would lead to a always false comparison.

Using the display-name, I've standardized the app name that would be deployed, and later on compared to a new archive to be redeployed.


Use the command listApplications() in Online mode to list all applications that are currently deployed in the WebLogic domain.

In the event of an error, the command returns a WLSTException.

Example :

wls:/mydomain/serverConfig> listApplications() 
SamplesSearchWebApp
asyncServletEar
jspSimpleTagEar
ejb30
webservicesJwsSimpleEar
ejb20BeanMgedEar
xmlBeanEar
extServletAnnotationsEar
examplesWebApp
apache_xbean.jar
mainWebApp
jdbcRowSetsEar

Source : link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜