确定 EAR 是否已使用 WLST 部署在 WebLogic Server 中?
我正在尝试创建一个简单的 python 脚本,将我的 EAR 文件部署到 Weblogic 的 AdminServer。我搜索了互联网和Oracle提供的文档,但找不到确定该应用程序是否之前已部署的方法。我希望我的脚本检查它是否已经存在,如果是,则发出重新部署命令。如果没有,请发出部署命令。
我尝试修改我找到的示例脚本,尽管它们有效,但它们的行为并不符合预期。我尝试做的事情之一是检查(使用 cd 命令)我的 EAR 是否位于 WebLogic 的部署文件夹中,如果是,则发出重新部署。如果没有,它应该抛出一个异常,我将在其中发出部署。但是,每次在脚本中发出 cd 命令时都会引发异常:
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
在使用 WLST 脚本工具设置环境变量后,我使用 execfile("C:\MyTestDeployer.py") 命令在 Windows 上运行此脚本。有什么想法吗?我还尝试在 cd 命令中使用不同的路径,但无济于事。有什么想法吗?
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("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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它对我有用:
It works for me:
我过去做过类似的事情,但采用了不同的方法...
我使用了 weblogic.Deployer 界面和 -listapps 选项来列出部署到域的应用程序/库,然后我将其与在存档中生成的 application.xml 的 display-name 元素
在我的例子中,我使用普通文件名发现的问题是存档带有生成日期。这会导致总是错误的比较。
使用显示名称,我标准化了将要部署的应用程序名称,然后与要重新部署的新存档进行比较。
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.
在联机模式下使用命令
listApplications()
列出当前部署在 WebLogic 域中的所有应用程序。如果发生错误,该命令将返回 WLSTException。
示例:
来源:链接
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 :
Source : link