WebLogic11 – Command Control

Posted on Posted in weblogic

In this post I’ll explain how control a Weblogic Server and Application from command line with simple task examples:

WebLogic Tools

CLASSPATH

Add the WebLogic Server classes to the CLASSPATH environment variable, and ensure that the correct JDK binaries are available in your PATH. You can use the setWLSEnv.sh or setWLSEnv.cmd script, located in the server/bin subdirectory of the WebLogic Server installation directory, to set the environment.

. /usr/local/oracle/middleware/wlserver_10.3/server/bin/setWLSEnv.sh

This is necesary to run WebLogic Scripting Tool or WebLogic Deployer.

WebLogic Scripting Tool

With this tool we have the posibility to start, stop, deploy…. a WebLogic server or Application, more info.

Stop/Start Aplication

  • Start the WLST:
java weblogic.WLST
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
wls:/offline>
  • Connect to your WebLogic Server:
wls:/offline> connect('weblogic','******','t3://weblogic.snaider.es:7001')
Connecting to t3://weblogic.snaider.es:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'WEBLOGIC'.
Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.
wls:/OBIEE/serverConfig>
  • Stop an aplication
wls:/offline> stopApplication('application1')
wls:/offline> startApplication('application1')
  • Disconnect
disconnect()
exit()

WebLogic Deployer

With this utility we have the oportunity to start/stop aplication , deploy local app, deploy a remote app, customize a deployment, etc.

Deploy a local app to Remote Weblogic

Before run WebLogic Deployer export de CLASSPATH

java weblogic.Deployer -adminurl t3://weblogic.cdr.snaider.es:7001 \
-username USERNAME -password ****** \
-name APP-NAME \
-targets APP-SERVER \
-deploy \
-upload FULL-PATH.war

 Undeploy app

To Undeploy a local or remote aplication:

java weblogic.Deployer -adminurl t3://weblogic.cdr.snaider.es:7001 \
-username USERNAME -password ******* \
-name APP-NAME \
-targets APP-SERVER \
-undeploy

 Deploy an app with a Deployment Plan

java weblogic.Deployer \
	-adminurl http://localhost:7001 \
	-username weblogic \
	-password weblogic \
	-deploy \
	-name APP-NAME \
	-source FULL-PATH/myAPP.war \
	-targets APP-SERVER \
	-stage \
	-plan FULL-PATH/plan.xml

 Deploy an app to more more than one targets

java weblogic.Deployer -adminurl t3://localhost:7001 \
-username USERNAME -password ****** \
-name APP-NAME \
-targets APP-SERVER1,APP-SERVER2 \
-deploy \
-upload FULL-PATH.war

Deploy to a Cluster

-DClusterConstraintsEnabled=true

Deployment Stage Modes

WebLogic Server provides three different options for staging files:

  • stage mode
  • nostage mode
  • external_stage mode

Stage Mode

The Administration Server first copies the deployment unit source files to the staging directories of target servers.
The staging directory is stage by default, and it resides under the target server’s root directory.

  • When copying files to the staging directory, the Administration Server creates a subdirectory with the same name as the deployment name.
  • The target servers then deploy using their local copy of the deployment files.
  • stage mode is the default mode for:
    • Administration Console when deploying to more than one WebLogic Server instance.
    • Managed Servers.
    • Weblogic.Deployer uses the target server’s staging mode as the default

Use when:

  • Deploying small or moderate-sized applications to multiple WebLogic Server instances.
  • Deploying small or moderate-sized applications to a cluster.
java weblogic.Deployer -adminurl t3://localhost:7001 \
-username USERNAME -password ****** \
-name APP-NAME \
-targets APP-SERVER1,APP-SERVER2 \
-stage \
-deploy \
-upload FULL-PATH.war

Nostage Mode

The Administration Server does not copy deployment files.

  • Stage directory is ignored.
  • Instead, all servers deploy using the same physical copy of the deployment files, which must be directly accessible by the Administration Server and target servers.
  • With nostage deployments of exploded archive directories, WebLogic Server automatically detects changes to a deployment’s JSPs or Servlets and refreshes the deployment. (This behavior can be disabled if necessary.)
  • Default mode used by Admin Console to deploy only to Admin Server.
  • Use when:
    • Deploying to a single-server domain.
    • Deploying to a cluster on a multi-homed machine.
    • Deploying very large applications to multiple targets or to a cluster where deployment files are available on a shared directory.
    • Deploying exploded archive directories that you want to periodically redeploy after changing content.
    • Deployments that require dynamic update of selected Deployment Descriptors via the Administration Console.
java weblogic.Deployer -adminurl t3://localhost:7001 \
-username USERNAME -password ****** \
-name APP-NAME \
-targets APP-SERVER1,APP-SERVER2 \
-nostage \
-deploy \
-upload FULL-PATH.war

Start app in Admin Mode

Prepares deployment files for deployment by copying deployment files to all target servers and validate it.

Is possible to start an application in Administration mode with option -adminmode, the application can be accessed only by internal clients through a configured Administration port. External clients cannot access the application.

java weblogic.Deployer -adminurl http://localhost:7001 -username weblogic
     -password weblogic -start -adminmode -name MY-APP-NAME
     /myDeployments/myApplication/

And now start an application in Client mode, all client have access:

java weblogic.Deployer -adminurl http://localhost:7001 -username weblogic
     -password weblogic -start -name MY-APP-NAME

Deploy Shared Java Libraries

java weblogic.Deployer -adminurl http://localhost:7001 -username weblogic
     -password weblogic -deploy -targets myserver1,myserver2
     -library /deployments/myLibraryApplication/

More Info

Official WebLocic.Deployer commands reference

Official WebLogic Scripting Tools reference

Leave a Reply

Your email address will not be published. Required fields are marked *