My Status: Planning for the Future...
____________________
 
0

weblogic.Deployer usage

Posted by cemetery on Dec 18, 2012 in Others

Below article provides some sample usages of the weblogic.Deployer utility.

weblogic.Deployer is a Java-based deployment tool that provides administrators and developers command-line based deployment operations.
Deploy application on admin server:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -deploy c:/myapps/myapp.ear

Deploy individual modules in application to different targets:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -targets mywar@webserver,myjar@ejbserver -deploy c:/myapps/myapp.ear

Undeploy application from specified targets:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -undeploy -targets server1,server2..

Redeploy application on current targets:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -redeploy

Redeploy individual module in an application:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -redeploy -targets moduleA@serverA,moduleA@serverB

Partially redeploy, for example, to update a JSP in a exploded webapp:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -redeploy mywar/index.jsp

The path of JSP to be updated is relative to the root of the application. If a directory is specified the entire subtree is updated.

Multiple servers sharing the same physical deployment:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -targets server1,server2 -nostage -deploy c:/myapps/myapp.ear

The -nostage option indicates that the application is available on all target servers at the same path and hence server should not copy files to the managed servers.

Deploy the first application version on admin server:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -deploy c:/myapps/myapp_v1.ear

Perform Production Redeployment of a new application version on admin server:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -redeploy -source c:/myapps/myapp_v2.ear

Note: The above feature is used for Side By Side deployment strategies ideally preferred for production environments.

Refer the below article know more about Side By Side deployment.

http://weblogic-wonders.com/weblogic/2009/12/02/side-by-side-deploymentversioning/

Deploy application to administration mode on admin server:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -deploy c:/myapps/myapp.ear -adminmode

Note: The above feature is ideally used for sanity testing so that the application can process only admin requests.

Transition application from administration mode to running on admin server:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -start

Transition application from running to administration mode on admin server:

java weblogic.Deployer -adminurl url -username username -password password -name myapp -stop -adminmode

Deploy a library on admin server:

java weblogic.Deployer -adminurl url -username username -password password -name mylib -library -libspecver 1.0 -libimplver 2.0 -deploy c:/myapps/mylib.jar

Note: This feature would deploy the file as library rather than as an application.

Deploy an application on admin server with a deployment plan:

java weblogic.Deployer -adminurl url -username username -password password -plan c:/myapps/myapp/plan/plan.xml -deploy c:/myapps/myapp/app/myapp.jar

Note: The above feature uses plan.xml to help administrators easily change an application’s WebLogic Server configuration for a specific environment without modifying existing Java EE or WebLogic-specific deployment descriptors.

Refer the below article for a sample usage of plan.xml

http://weblogic-wonders.com/weblogic/2009/11/29/plan-xml-usage-for-message-driven-bean/

Update an application configuration:

java weblogic.Deployer -adminurl url -username username -password password -plan c:/myapps/myapp/plan/newplan.xml -name myapp -update

Deploy a queue to a specific JMS server:

java weblogic.Deployer -adminurl url -username username -password password -submoduletargets myqueue@myjmsmodule@JMSServer -deploy c:/myapps/myapp/app/myapp.ear

For documentation on weblogic.Deployer refer the below link:-

http://download.oracle.com/docs/cd/E14571_01/web.1111/e13702/wldeployer.htm

For trouble shooting deployment issues refer the below article.

http://weblogic-wonders.com/weblogic/2010/11/30/deployment-issues-on-weblogic-server/

Note: In the above examples we are specifying the username and password in plain text format and that could cause a security issue.

You can use the STOREUSERCONFIG feature of the weblogic.Admin utility which generates userconfig file and userkey file containing an encrypted username and password.

Refer the below article for more information on userconfig and userkey files.

http://weblogic-wonders.com/weblogic/2009/11/30/steps-to-use-userconfig-file-and-userkey-file/

For example, deploying an ear file using the userConfigFile feature is below.

java weblogic.Deployer -userconfigfile C:/bea103/storeconfig/config-file -userkeyfile C:/bea103/storeconfig/keyfile -name myapp -targets MS1,MS2 -deploy C:/myapps/myapp.ear

—-

Uploading Deployment Files from a Remote Client

 
java weblogic.Deployer \
    -adminurl http://localhost:7001 \
    -username weblogic \
    -password weblogic \
    -deploy \
    -upload \
    c:\localfiles\myapp.ear

* Uploaded to server’s upload directory (defaults to ?).

Deploying to a Single-Server Domain

 
java weblogic.Deployer \
   -adminurl http://localhost:7001 \
   -username weblogic \
   -password weblogic \
   -deploy \
   -name myTestApplication \
   c:\localfiles\myapp.ear

Deploying an Application with a Deployment Plan

 
java weblogic.Deployer \
	-adminurl http://localhost:7001 \
	-username weblogic \
	-password weblogic \
	-deploy \
	-name myTestDeployment \
	-source /myDeployments/installedApps/myApplication/app/myApplication.ear \
	-targets myCluster \
	-stage \
	-plan /myDeployments/installedApps/myApplication/plan/plan.xml

Deploying an Application That Looks Up System Resources from JNDI During preStart

* Create and activate desired system resources in a separate session before deploy the application that relies on it.

Targeting Deployments to Servers, Clusters, and Virtual Hosts

* Deploy to sinple target:

 
java weblogic.Deployer \
	-adminurl http://localhost:7001 \
	-username weblogic \
	-password weblogic \
	-deploy \
	-targets companyHost c:\localfiles\myWebApp.ear

* Deploy to more than one targets:

 
java weblogic.Deployer \
    -adminurl http://localhost:7001 \
    -username weblogic \
    -password weblogic \
    -deploy \
    -targets ManagedServer-1,ManagedServer-2 \
    c:\localfiles\myapp.ear

* Deploy to a cluster target:
- To enforce strict deployment for all servers configured in a cluster:

 
-DClusterConstraintsEnabled=true

Using Module-Level Targeting for Deploying an Enterprise Application

Target individual modules in an enterprise application

 
java weblogic.Deployer \
	-adminurl http://localhost:7001 \
	-username weblogic \
	-password weblogic \ 
	-name myEnterpriseApp \
	-targets module1@myserver1,module2@myserver2,module3@myserver3 \
	-stage \
	-deploy c:\localfiles\myEnterpriseApp.ear

Targeting Web Application Modules

- To target Web application modules that are part of an .ear file, you can use the Web application’s context-root name as the module name or specify the web-uri.
- If

 
<module>
  <web>
    <web-uri>myweb.war</web-uri>
    <context-root>/welcome</context-root>
  </web>
</module>

You can use context-root:

 
java weblogic.Deployer \
	-adminurl http://localhost:7001 \
	-username weblogic \
	-password weblogic \
	-name mywebapplication \
	-targets /welcome@myserver1 \
	-stage \
	-deploy c:\localfiles\myEnterpriseApp.ear

Or web uri:

 
java weblogic.Deployer \
	-adminurl http://localhost:7001 \
	-username weblogic \
	-password weblogic \
	-name mywebapplication \
	-targets myweb.war@myserver1 \
	-stage \
	-deploy c:\localfiles\myEnterpriseApp.ear

- For default context root, i.e. ‘/’

 
<module>
  <web>
    <web-uri>myweb.war</web-uri>
    <context-root>/</context-root>
  </web>
</module>

Then only

 
java weblogic.Deployer \
	-adminurl http://localhost:7001 \
	-username weblogic \
	-password weblogic \
	-name mywebapplication \
	-targets /@myserver1 \
	-stage \
	-deploy c:\localfiles\myEnterpriseApp.ear

Deploying JDBC, JMS, and WLDF Application Modules

* Only available to the server to which they are targeted.
- Need to target to multiple servers or cluster to be available on them.

Targeting Application-Scoped JMS, JDBC, and WLDF Modules

* Application-scoped resource modules can be targeted independently of other EAR modules during deployment, if necessary, by using module-level targeting syntax.
* For example:

 
java weblogic.Deployer 
	-adminurl http://localhost:7001 
	-username weblogic
	-password weblogic 
	-name myEnterpriseApp
	-targets myWebApp@myCluster,myJDBCModule@myserver1,myEJBModule@myserver1 
	-stage 
	-deploy c:\localfiles\myEnterpriseApp.ear

Sub-module Targeting for Standalone JMS Modules

* For a standalone JMS module, the submodule targeting syntax is: -submoduletargets submodule_name@target_name.
* For example, to deploy a standalone JMS module on a single server instance, targeting the submodule myQueue to a JMS Server named JMSServer1, enter the command:

 
java weblogic.Deployer -adminurl http://localhost:7001 -username weblogic
   -password weblogic -name myJMSModule
   -targets ManagedServer1 -submoduletargets myQueue@JMSServer1
   -deploy c:\localfiles\myJMSModule.xml

* To undeploy the same JMS module, enter the following command, which, assuming myJMSModule contains more than one submodule, will undeploy only the myQueue submodule; all other submodules are unaffected.

 
java weblogic.Deployer -adminurl http://localhost:7001 -username weblogic
   -password weblogic -name myJMSModule
   -undeploy -submoduletargets myQueue@JMSServer1

Sub-module Targeting for Application-scoped JMS Modules

* For an application-scoped JMS module in an EAR, use the syntax: submodule_name@module_name@target_name to target a submodule.
* For example, if the queue in the above example were instead packaged as part of an Enterprise application, you would use the command:

 
java weblogic.Deployer -adminurl http://localhost:7001 -username weblogic
   -password weblogic -name myEnterpriseApp
   -targets ManagedServer1 -submoduletargets myQueue@myJMSModule@JMSServer1
   -deploy c:\localfiles\myEnterpriseApp.ear

* To undeploy the same JMS module, enter the following command, which, assuming myEnterpriseApp contains more than one submodule, will undeploy only the myQueue submodule; all other submodules are unaffected.

 
java weblogic.Deployer -adminurl http://localhost:7001 -username weblogic
   -password weblogic -name myEnterpriseApp
   -undeploy -submoduletargets myQueue@myJMSModule@JMSServer1

Deployment Stage Modes

* Determines how deployment files are made available to target servers that must deploy an application or standalone module.
* WebLogic Server provides three different options for staging files:
- stage mode,
- nostage mode,
- external_stage mode.

nostage Mode

* The Administration Server does not copy deployment unit 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.
* Syntax

 
java weblogic.Deployer 
    -adminurl http://localhost:7001 
    -username weblogic
    -password weblogic 
    -name mydeploymentname 
   -targets myserver1,myserver2,myserver3 
   -nostage 
   -deploy c:\localfiles\myapp.ear

stage Mode

* The Administration Server first copies the deployment unit source files to the staging directories of target servers.
- The staging directory is named 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.
* Syntax:

 
java weblogic.Deployer -adminurl http://localhost:7001 -username weblogic
   -password weblogic -name mydeploymentname 
   -targets myserver1,myserver2,myserver3 -stage 
   -deploy c:\localfiles\myapp.ear

external_stage Mode

* Similar to stage mode, i.e. target servers deploy apps using local copies of deployment files.
* You have to copy files to each target server’s staging directory manually.
- Deployment files must be stored in a subdirectory that reflects the deployment name.

 
cd WL_HOME/stage
mkdir myEARExternal/2.0Beta
cp myear myEARExternal/2.0Beta

* Use when you deploy very large applications to multiple machines and
- do not have a shared file system
- cannot use nostage mode
* Use the -noversion option to turn off the requirement that deployment files be on the Administration Server, but the -noversion option causes versioning information to be ignored so you cannot use the -noversion option with versioned applications.
* Syntax:

 
java weblogic.Deployer -adminurl http://localhost:7001 -name weblogic
   -password weblogic -external_stage -name myEARExternal 
   -deploy c:\myapps\myear

Changing the Default Staging Behavior for a Server

* The server staging mode specifies the default deployment mode for a server if none is specified at deployment time, e.g. weblogic.Deployer.
* You can only change the server staging mode by using the Administration Console or by directly changing the ServerMBean via JMX.
* Changing the server staging mode does not affect existing applications.
- If you want to change the staging mode for an existing application, you must undeploy the application deployment and then redeploy it with the new staging mode.
* How to change

Distributing Applications to a Production Environment

Overview

* Copy application deployment files to all target servers and validate it.
* Application can be started in Admin mode after distribution (use the -adminmode option).

Syntax

 
java weblogic.Deployer -adminurl http://localhost:7001 -username weblogic
     -password weblogic -distribute -name myTestDeployment
     /myDeployments/myApplication/

Start Application in Admin Mode

* Restricts access to the application to a configured Administration channel.
* Allows you to distribute the application or new version to a production environment without opening the application to external client connections.
* Need to configure an administration channel.
* Start a Distributed Application in admin mode:

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

* Starting a Distributed Application for new client connections:

 
java weblogic.Deployer -adminurl http://localhost:7001 -username weblogic
     -password weblogic -start -name myTestDeployment

Deploying Shared Java EE Libraries and Dependent Applications

* A Java EE library is
- a standalone Java EE module,
- multiple Java EE modules packaged in an Enterprise application (EAR),
- or a plain JAR file that is registered with the Java EE application container upon deployment.
* After a Java EE library has been registered, you can deploy Enterprise applications that reference the library.
* Each referencing application receives a copy of the shared Java EE library module(s) on deployment (merging), and can use those modules as if they were packaged as part of the application itself.
* Need to redeploy all referencing applications after new version of library is deployed.
* Deploy as a library:

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

* Should always specify a libary version number:
- in manifest file
- use libspecver and/or libimplver options.

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

* Deploying applications that reference libraries as ususal.
- All referenced libraries are registered on the application’s target servers.
- Registered libraries meet the version requirements of the referencing application.


Tags:

Copyright © 2020 Bùi Hoài Nam – cemetery All rights reserved. Theme by Laptop Geek.