qdj
qdj

Reputation: 21

How to deploy a War file using T3 protocol (weblogic) with Java?

I don't know how to deploy a War file remotely through T3 protocol with Java.

I would like to use a Java code to deploy War files remotely through T3 protocol. I don't how to do that with Java. I don't want to use weblogic.Deployer: I would like to use Java code.

Someone has a Java example to deploy a War file remotely (through T3 protocol, through a JNDI)?

Otherwise, is it possible to execute system commands on a remote weblogic through T3 protocol thanks to an admin JNDI?

Thank you in advance,

Upvotes: 0

Views: 2192

Answers (2)

STaefi
STaefi

Reputation: 4377

I have not any java code to utilize t3 protocol for deploying artifacts on weblogic, but I think the followings commandline command would help you through writing such a code:

In windows command-line:

For deploying war files as an application:

C:\Users\s.taefi>java -classpath C:\Oracle\Middleware\Oracle_Home\wlserver\server\lib\weblogic.jar weblogic.Deployer -adminurl t3://localhost:7001 -username [Your username] -password [Your password] -upload -targets AdminServer -deploy -source [path to your war file]

For deploying war files as shared-library:

C:\Users\s.taefi>java -classpath C:\Oracle\Middleware\Oracle_Home\wlserver\server\lib\weblogic.jar weblogic.Deployer -adminurl t3://localhost:7001 -username [Your username] -password [Your password] -upload -library -targets AdminServer -deploy -source [path to your war file]

These are tested using:

  • Windows7 x64

  • Weblogic 12c

Good Luck.

Upvotes: 0

Display Name is missing
Display Name is missing

Reputation: 6227

Yes you can deploy directly with java. Use the term JMX in your searches if you are struggling to find java specific code:

import weblogic.deploy.api.tools.*;  //SesionHelper
import weblogic.deploy.api.spi .*;  //WebLogicDeploymentManager

....

String protocol="t3";
String hostName="localhost";
String portString="7001";
String adminUser="weblogic";
String adminPassword="weblogic";

WebLogicDeploymentManager deployManager=SessionHelper.getRemoteDeploymentManager( protocol,hostName,portString,adminUser,adminPassword);

DeploymentOptions options = new DeploymentOptions();
Target targets[]=deployManager.getTargets();
Target deployTargets[]=new Target[1];
deployTargets[0]=targets[0]; //admin server

String appName="EARFile";
options.setName(appName);
ProgressObject processStatus=deployManager.distribute(deployTargets, new File("EARFile.ear"), null,options);
processStatus=deployManager.deploy(deployTargets, new File("EARFile.ear"), null,options);
DeploymentStatus stat = processStatus.getDeploymentStatus() ;
System.out.println("For EARFile.ear DeploymentStatus.getState(): " + stat.getState());

Upvotes: 1

Related Questions