使用 wlfullclient.jar 在 WebLogic 10.3.4 上部署已安装的应用程序

发布于 2025-01-01 04:55:16 字数 1360 浏览 1 评论 0原文

我安装了一个名为 HelloWorld 的应用程序,但尚未部署。它的状态是 Installed,如下所示:

在此处输入图像描述

当我尝试部署时它在目标服务器上,例如 AdminServer,它会创建一个名为 helloworld.war 的新应用程序,该应用程序部署在 AdminServer 而原来的HelloWorld 应用程序保持在 Installed 状态。应用 helloworld.war 是处于状态 Active 的应用...快照:

在此处输入图像描述

这是我用来部署已安装的应用程序的代码:

File warFilePath = new File("c:/helloworld.war"); // war file path on AdminServer machine

Target adminServerTarget = deployManager.getTarget("AdminServer");
WebLogicTargetModuleID targetModuleID = deployManager.createTargetModuleID(
        "HelloWorld", ModuleType.WAR, adminServerTarget);
WebLogicTargetModuleID[] targetModuleIDs = new WebLogicTargetModuleID[1];
targetModuleIDs[0] = targetModuleID;

ProgressObject redeployProcessObject =
    deployManager.redeploy(targetModuleIDs, warFilePath, null /*no deployment plan*/ );

不过,有两个令人惊讶的事实。

首先,当在 WebLogic 版本 9.x 到 10.3.3 上运行此代码时,它运行良好。

其次,当从 WLST 提示符运行此代码时,使用 jython 即使在版本 10.3.4 上它也能很好地工作(我可以附加确切的命令,尽管它们与java 除了语法采用之外)...

我的问题是,如何使其在 10.3.4 上也能工作?

I have an application named HelloWorld installed, yet not deployed. Its state is Installed, like such:

enter image description here

When I'm trying to deploy it on target server, say AdminServer, it results in creating a new application named helloworld.war which is deployed on AdminServer whereas the original HelloWorld app remains in Installed state. App helloworld.war is the one that is in state Active... Snapshot:

enter image description here

Here's the code I use to deploy the already installed app:

File warFilePath = new File("c:/helloworld.war"); // war file path on AdminServer machine

Target adminServerTarget = deployManager.getTarget("AdminServer");
WebLogicTargetModuleID targetModuleID = deployManager.createTargetModuleID(
        "HelloWorld", ModuleType.WAR, adminServerTarget);
WebLogicTargetModuleID[] targetModuleIDs = new WebLogicTargetModuleID[1];
targetModuleIDs[0] = targetModuleID;

ProgressObject redeployProcessObject =
    deployManager.redeploy(targetModuleIDs, warFilePath, null /*no deployment plan*/ );

There are two surprising facts, though.

First, when running this code on WebLogic versions 9.x to 10.3.3 it works great.

Second, when running this code from WLST prompt, with jython it also works great even on version 10.3.4 (I can attach the exact commands although they're the same as java except for syntactic adoptions)...

My question is, how do I make it work also on 10.3.4?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七月上 2025-01-08 04:55:16

我应该以为没有人会回答这个问题...:)

无论如何,我找到了解决方案。我应该使用 deploy 而不是 redeploy,并使用 DeploymentOptions ,其名称是现有应用程序名称(HelloWorld ):

      ProgressObject redeployProcessObject = null;
      try {
          final DeploymentOptions options = new DeploymentOptions();
          options.setName(applicationName);
          redeployProcessObject = deployManager.deploy(
              targetModuleIDs, warFilePath, null /*no deployment plan*/, options);
      } catch (TargetException e) {
          final String message =
                  String.format("Deployment of application %s on target %s failed: %s",
                          applicationName, allTargets, e.getMessage());
          _log.error(message, e);
      }

根据文档redeploy 仅用更新版本替换当前应用程序文件和计划。而 deploy 将文件(从 AdminServer)分发到目标并启动应用程序。

另外,在深入研究 WebLogic 的 jython 脚本和 jar 后,我发现这正是在 WLST 中调用 redeploy 时所做的事情。

I should have thought that no one would answer this question... :)

Anyway, I found a solution. I should have used deploy instead of redeploy, with a DeploymentOptions of which name is the existing application name (HelloWorld):

      ProgressObject redeployProcessObject = null;
      try {
          final DeploymentOptions options = new DeploymentOptions();
          options.setName(applicationName);
          redeployProcessObject = deployManager.deploy(
              targetModuleIDs, warFilePath, null /*no deployment plan*/, options);
      } catch (TargetException e) {
          final String message =
                  String.format("Deployment of application %s on target %s failed: %s",
                          applicationName, allTargets, e.getMessage());
          _log.error(message, e);
      }

According to the docs, redeploy only replaces the current application files and plan with an updated version. Whereas deploy distributes the files (from the AdminServer) to the target(s) and starts the application.

Also, after digging deep in WebLogic's jython scripts and jars I found out that this is exactly what's done when invoking redeploy in the WLST.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文