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

时间:2012-01-31 13:49:42

标签: java weblogic weblogic-10.x weblogic11g

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

enter image description here

当我尝试在目标服务器上部署它时,比如AdminServer,这会导致创建一个名为 helloworld.war 的新应用程序,该应用程序部署在< / strong> AdminServer而原始HelloWorld应用仍处于Installed状态。应用helloworld.war是状态Active ...快照:

enter image description here

以下是我用于部署已安装的应用的代码:

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上也能正常工作?

1 个答案:

答案 0 :(得分:0)

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

无论如何,我找到了解决方案。我应该使用deploy而不是redeployDeploymentOptions的名称是现有的应用名称(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);
      }

根据docsredeploy仅替换当前的应用程序文件并使用更新版本进行规划。而deploy将文件(从AdminServer)分发到目标并启动应用程序。

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