deploy already installed application on WebLogic 10.3.4 using wlfullclient.jar
-
06-12-2019 - |
Frage
I have an application named HelloWorld
installed, yet not deployed. Its state is Installed
, like such:
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:
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?
Lösung
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.