C Using the WebLogic Maven Plug-In for Deployment

This appendix describes using the weblogic-maven-plugin for deployment in WebLogic Server 12.1.3.

Note:

This plug-in is deprecated in version 12.1.2 of WebLogic Server.

Oracle recommends that you instead use the WebLogic Server Maven plug-in. See Developing Applications Using Continuous Integration for complete documentation.

Apache Maven is a software tool for building and managing Java-based projects. WebLogic Server provides support for Maven through the provisioning of plug-ins that enable you to perform various operations on WebLogic Server from within a Maven environment.

The weblogic-maven-plugin described in this chapter was delivered in WebLogic Server 11g Release 1, and provides support for deployment operations similar to those supported by the command-line utility, weblogic.Deployer.

Both plug-ins are certified with Maven 2.x and 3.x.

This appendix includes the following sections:

To download and configure Maven on supported platforms, see http://maven.apache.org/download.html. Be sure to read the set up instructions closely to ensure that Maven is working correctly in your environment.

For detailed information on using Maven to build applications and projects, see the Maven Users Centre at http://maven.apache.org/users/index.html.

Configuring and Using the WebLogic Maven Plug-In for Deployment

Follow these steps for generating, installing, and using the weblogic-maven-plugin:

Note:

To successfully accomplish these steps, your computer must be connected to the Internet and have the necessary proxy settings configured correctly in the settings.xml file (typically $HOME/.m2/settings.xml). For further details, see http://maven.apache.org/guides/mini/guide-proxies.html.
  1. Build the plug-in JAR file using the WebLogic JarBuilder Tool (wljarbuilder) under ORACLE_HOME/wlserver/server/lib/ with the following command:

    java -jar wljarbuilder.jar -profile weblogic-maven-plugin
    

    The weblogic-maven-plugin.jar contains a Project Object Model (pom.xml) file which specifies the groupId, artifactId, version, and packaging of the weblogic-maven-plugin.jar:

    groupId=com.oracle.weblogic
    artifactId=weblogic-maven-plugin
    version=12.1.1.0
    packaging=maven-plugin
    

    These fields identify the plug-in and mark a specific place in a Maven repository, acting like a coordinate system for Maven projects.

    Note:

    As of WebLogic Server 10.3.5, the plug-in version number has been changed to match the WebLogic Server version number and must include four digits, for example, 10.3.5.0, 10.3.6.0, 12.1.1.0.
  2. Copy the generated weblogic-maven-plugin.jar to a temporary directory (/tmp).

    For example:

    mkdir c:\tmp
    cd c:\tmp
    cp C:\ORACLE_HOME\wlserver\server\lib\weblogic-maven-plugin.jar c:\tmp
    
  3. Extract the pom.xml file from weblogic-maven-plugin.jar under the c:\tmp directory.

    For example:

    jar xvf c:\tmp\weblogic-maven-plugin.jar
    META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml
    
  4. Provision the weblogic-maven-plugin.jar in your local Maven repository with the following command. However, for a shortened command-line goal invocation of the plug-in, follow the directions in step 6 before performing this step.

    mvn install:install-file 
    -Dfile=c:\tmp\weblogic-maven-plugin.jar
    -DpomFile=META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml
    

    Typical command output is like the following:

    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'install'.
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Maven Default Project
    [INFO] task-segment: [install:install-file] (aggregator-style)
    [INFO] ------------------------------------------------------------------------
    Downloading:
    http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/
    maven-plugin-api-2.0.6.pom
    
    Downloading:
    http://repo1.maven.org/maven2/org/apache/maven/maven/2.0.6/maven-2.0.6.pom
    
    Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-project/2.0.6/
    maven-project-2.0.6.pom
    
    Downloading:
    http://repo1.maven.org/maven2/org/apache/maven/maven-settings/2.0.6/
    maven-settings-2.0.6.pom
    ...................
    
    Downloading:
    http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-digest/
    1.0/plexus-digest-1.0.jar
    
    [INFO] [install:install-file {execution: default-cli}]
    [INFO] Installing C:\tmp\weblogic-maven-plugin.jar to C:\depot\.m2\
    repository\com\oracle\weblogic\weblogic-maven-plugin\12.1.1.0\weblogic-maven-plugin-12.1.1.0.jar
    [INFO] Installing C:\tmp\META-INF\maven\com.oracle.weblogic\weblogic-maven-plugin
    pom.xml to C:\depot\.m2\repository\com\oracle\weblogic\
    weblogic-maven-plugin\12.1.1.0\weblogic-maven-plugin-12.1.1.0.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1 minute 7 seconds
    [INFO] Finished at: Mon Nov 21 13:20:37 PST 2011
    [INFO] Final Memory: 3M/15M
    [INFO] ------------------------------------------------------------------------
    

    Note:

    Because the mvn install command downloads Maven dependencies from the Internet which are required for the successful execution of Maven goals, you must have run mvn install at least once on your local machine.
  5. Use the Maven plug-in by employing either of the following methods:

    Note:

    As of WebLogic Server 10.3.6, you can execute weblogic-maven-plugin goals outside of a Maven project. For example, you can use the weblogic:deploy goal as a standalone operation to deploy a WAR file from any directory; the directory need not contain a Maven pom.xml file.
    • From the command line—By invoking a goal from the command line.

      For example, using the goal full name to deploy:

      mvn com.oracle.weblogic:weblogic-maven-plugin:deploy
      

      Or, optionally, if you've configured using the shortened command-line goal invocation (see Step 6):

      mvn weblogic:deploy
      
    • From a POM file—By including the Maven plug-in in the application's pom.xml file.

      You add the plug-in into any life cycle phase of the project. Optionally, you can add a goal to any of the default Maven life cycle phases by adding an executions tag in the pom.xml file. The goal is then bound to that particular phase of the Maven life cycle. For example, as shown in Example C-1, the goal is bound to the "install" phase of the Maven life cycle. By doing this, every time you run the mvn install command, the deployment plug-in is also called.

      Example C-1 Maven Project pom.xml File

      <build> 
        <plugins> 
         <plugin> 
            <groupId>com.oracle.weblogic</groupId> 
            <artifactId>weblogic-maven-plugin</artifactId> 
            <version>12.1.1.0</version> 
            <configuration> 
                <adminurl>t3://localhost:7001</adminurl>
                <user>weblogic</user> 
                <password>weblogic123</password> 
                <upload>true</upload> 
                <action>deploy</action> 
                <remote>false</remote> 
                <verbose>true</verbose> 
      <source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source> 
               <name>${project.build.finalName}</name> 
            </configuration> 
            <!-- 
            <executions> 
               <execution> 
                  <phase>install</phase> 
                    <goals> 
                      <goal>deploy</goal> 
                    </goals> 
               </execution> 
             </executions> 
             --> 
        </plugin> 
          . 
          . 
          . 
       </plugins> 
      </build> 
      
  6. Optionally, you can install the plug-in so that you can use it with a shortened name (weblogic) instead of the full name (com.oracle.weblogic:weblogic-maven-plugin), greatly increasing its ease of use. To accomplish this you need to edit the pom.xml file to add the additional <build> stanza, as shown in Example C-2, and execute the mvn install command, before installing the weblogic-maven-plugin.

    1. Modify the settings.xml file located in your $HOME/.m2 directory, as follows:

      <!-- pluginGroups
       | This is a list of additional group identifiers that will be searched 
       | when resolving plugins by their prefix, for example, when invoking a  
       | command line like "mvn prefix:goal". Maven will automatically add the 
       | group identifiers "org.apache.maven.plugins" and "org.codehaus.mojo"
       | if theses are not already contained in the list.
       | -->
      <pluginGroups>
         <!-- pluginGroup
            | Specifies a further group identifier to use for plugin lookup.
          -->
         <pluginGroup>com.oracle.weblogic</pluginGroup>
       </pluginGroups>
      
    2. Edit the c:\tmp\META-INF\maven\com.oracle.weblogic\weblogic-maven-plugin\pom.xml file, as follows:

      Example C-2 pom.xml File

      <project xmlns="http://maven.apache.org/POM/4.0.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
      http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.oracle.weblogic</groupId>
        <artifactId>weblogic-maven-plugin</artifactId>
        <packaging>maven-plugin</packaging>
        <version>12.1.1.0</version>
        <name>Maven Mojo Archetype</name>
        <url>http://maven.apache.org</url>
        <dependencies>
          <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>2.0</version>
          </dependency>
        </dependencies>
       
        <build>
         <plugins>
            <plugin>
             <artifactId>maven-plugin-plugin</artifactId>
             <version>2.3</version>
             <configuration>
               <goalPrefix>weblogic</goalPrefix>
             </configuration>
            </plugin>
          </plugins>
        </build>
       
      </project>
      
    3. From within c:\tmp, run the mvn install command.

      mvn install
      

      This step sets up the local Maven environment to allow the plug-in to use the weblogic goal prefix.

    4. From within c:\tmp, provision the weblogic-maven-plugin.jar in your local Maven repository, as follows:

      mvn install:install-file 
      c:\tmp\weblogic-maven-plugin.jar
      -DpomFile=c:\tmp\META-INF\maven\com.oracle.weblogic\weblogic-maven-plugin\pom.xml
      
    5. Now, you can use a shortened command-line goal invocation, such as:

      mvn weblogic:deploy
      

Supplying Secure User Credentials

In order to connect to the WebLogic Server domain to perform deployment operations, the weblogic-maven-plugin must supply valid user credentials. For quick and simple cases, this is typically done by specifying the user name and password directly in the Maven pom.xml file, as shown in Example C-1. However, this results in the user name and password entries being stored in clear-text form. To avoid this password exposure, you can optionally use a secure configuration authentication mechanism which stores the user name and password in encrypted form in an external file, and then uses it to supply the user credentials with which to connect to the WebLogic Server domain, along with the key that was used to encrypt the file. For more information, see "Securing Access from WLST Online" in Understanding the WebLogic Scripting Tool and User Credentials Arguments.

The following steps show you how to create and store a user configuration file and key file using WLST, and how to reference them in the Maven pom.xml file.

  1. Invoke WLST, connect to a running Administration Server, and use the WLST storeUserConfig command to specify the locations of the userConfigFile and userKeyFile that will be generated.

    >java weblogic.WLST
    wls:/offline>connect('weblogic','password')
    wls:/mydomain/serverConfig>storeUserConfig('/tmp/wls.config','/tmp/wls.key')
    Creating the key file can reduce the security of your system if it is not kept in
    a secured location after it is created. Do you want to create the key file? y or n
    y
    The username and password that were used for this current WLS connection are
    stored in /tmp/wls.config and /tmp/wls.key
    

    You can validate that these files work correctly using weblogic.Deployer to connect to the WebLogic Server domain, using the -userconfigfile and –userkeyfile parameters, as follows:

    java weblogic.Deployer -adminurl t3://localhost:7001
    -userconfigfile /tmp/wls.config -userkeyfile /tmp/wls.key –listapps
    
  2. To use the secure configuration authentication mechanism with the WebLogic Maven plug-in, you must install an additional library, <ORACLE_HOME>/wlserver/server/lib/crypto.jar, into the Maven repository to support the encryption operations, then add it as a dependency of the weblogic-maven-plugin via its pom.xml file.

    1. Install crytpo.jar into the Maven repository, as follows:

      cd <ORACLE_HOME>
      cd wlserver
      cd server
      cd lib
      mvn install:install-file -Dfile=cryptoj.jar -DgroupId=com.oracle.cryptoj
      -DartifactId=cryptoj -Dversion=1.0 -Dpackaging=jar
      
    2. To generate the weblogic-maven-plugin and its pom.xml file, follow steps 1, 2, and 3 in Configuring and Using the WebLogic Maven Plug-In for Deployment.

    3. Edit pom.xml to specify the crytpo.jar dependency and goalPrefix, a configuration section that lets you use the shortened command-line goal invocation of the plug-in.

      See Example C-3, an edited pom.xml file with changes at lines [16-22] and [24-35].

      Example C-3 Maven Project pom.xml File

      1:  <project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
      http://maven.apache.org/maven-v4_0_0.xsd">
      2:    <modelVersion>4.0.0</modelVersion>
      3:    <groupId>com.oracle.weblogic</groupId>
      4:    <artifactId>weblogic-maven-plugin</artifactId>
      5:    <packaging>maven-plugin</packaging>
      6:    <version>12.1.1.0</version>
      7:    <name>Maven Mojo Archetype</name>
      8:    <url>http://maven.apache.org</url>
      9:    <dependencies>
      10:      <dependency>
      11:        <groupId>org.apache.maven</groupId>
      12:        <artifactId>maven-plugin-api</artifactId>
      13:        <version>2.0</version>
      14:      </dependency>
      15:
      16:      <!-- Dependency on cryptoj library -->
      17:      <dependency>
      18:        <groupId>com.oracle.cryptoj</groupId>
      19:        <artifactId>cryptoj</artifactId>
      20:        <version>1.0</version>
      21:      </dependency>
      22:    </dependencies>
      23:
      24:    <!-- Use weblogic goalPrefix -->
      25:    <build>
      26:      <plugins>
      27:        <plugin>
      28:          <artifactId>maven-plugin-plugin</artifactId>
      29:          <version>2.3</version>
      30:          <configuration>
      31:             <goalPrefix>weblogic</goalPrefix>
      32:          </configuration>
      33:        </plugin>
      34:      </plugins>
      35:    </build>
      36:  </project>
      
  3. Install weblogic-maven-plugin into the Maven repository by using the following two install commands. The first command implicitly uses the edited pom.xml file and configures the weblogic-maven-plugin inside the Maven repository. The second command performs the installation of the weblogic-maven-plugin library into the Maven repository.

    Ensure that the edited pom.xml file is in the directory in which you will execute these commands.

    For Maven 2.x:

    mvn install
    mvn install:install-file -Dfile=weblogic-maven-plugin.jar -DpomFile=pom.xml 
    

    For Maven 3.x:

    mvn install -Dfile=weblogic-maven-plugin
    mvn install:install-file -Dfile=weblogic-maven-plugin.jar -DpomFile=pom.xml
    
  4. Configure pom.xml to use the secure configuration files for authentication.

    Example C-4 shows a fully configured Maven pom.xml for a Java EE 5 Web application. Lines [13-18] show the creation of the properties that identify the location of the relevant external files generated from WLST. Lines [67-69] show the use of the <userConfigFile> and <userKeyfile> elements to specify using the secure configuration files for authentication.

    Example C-4 Maven pom.xml With Secure Authentication

    1:  <project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    2:    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    http://maven.apache.org/xsd/maven-4.0.0.xsd">
    3:    <modelVersion>4.0.0</modelVersion>
    4:
    5:    <groupId>sab.demo.maven</groupId>
    6:    <artifactId>webapp</artifactId>
    7:    <packaging>war</packaging>
    8:    <version>1.0-SNAPSHOT</version>
    9:
    10:    <name>webapp JEE5 Webapp</name>
    11:    <url>http://maven.apache.org</url>
    12:
    13:    <!-- weblogic-maven-plugin properties -->
    14:    <properties>        
    15:      <weblogic.adminurl>t3://localhost:7001</weblogic.adminurl>    
    16:      <weblogic.configfile>/tmp/wls.config</weblogic.configfile>
    17:      <weblogic.keyfile>/tmp/wls.key</weblogic.keyfile>
    18:    </properties>  
    19:
    20:    <dependencies>
    21:
    22:      <dependency>
    23:        <groupId>javax.servlet</groupId>
    24:        <artifactId>servlet-api</artifactId>
    25:        <version>2.5</version>
    26:        <scope>provided</scope>
    27:      </dependency>
    28:
    29:      <dependency>
    30:        <groupId>javax.servlet.jsp</groupId>
    31:        <artifactId>jsp-api</artifactId>
    32:        <version>2.1</version>
    33:        <scope>provided</scope>
    34:      </dependency>
    35:
    36:      <dependency>
    37:        <groupId>junit</groupId>
    38:        <artifactId>junit</artifactId>
    39:        <version>3.8.1</version>
    40:        <scope>test</scope>
    41:      </dependency>
    42:
    43:    </dependencies>
    44:
    45:    <build>
    46:      <plugins>
    47:        <plugin>
    48:          <groupId>org.apache.maven.plugins</groupId>
    49:          <artifactId>maven-compiler-plugin</artifactId>
    50:          <version>2.0.2</version>
    51:          <configuration>
    52:            <source>1.5</source>
    53:            <target>1.5</target>
    54:          </configuration>
    55:        </plugin>
    56:
    57:      <plugin>
    58:          <groupId>com.oracle.weblogic</groupId>
    59:          <artifactId>weblogic-maven-plugin</artifactId>
    60:          <version>12.1.1.0</version>
    61:          <configuration>
    62:              <adminurl>${weblogic.adminurl}</adminurl>
    63:              <!--
    64:              <user>${weblogic.user}</user>
    65:              <password>${weblogic.password}</password>                                
    66:              -->
    67:              <!-- Use external connection files -->
    68:              <userConfigFile>${weblogic.configfile}</userConfigFile>
    69:              <userKeyFile>${weblogic.keyfile}</userKeyFile>
    70:              <source>
    71:                  ${project.build.directory}/${project.build.finalName}.${project.packaging}
    72:              </source>
    73:              <name>${project.build.finalName}</name>
    74:          </configuration>
    75:       </plugin>
    76:
    77:      </plugins>
    78:
    79:      <finalName>webapp</finalName>
    80:    </build>
    81:  </project>
    
  5. Verify that the secure configuration authentication mechanism works by using the list-apps goal—This goal does not perform any deployment operation, but does connect to the target server, authenticates, and returns a list of the currently deployed applications.

    Note the [INFO] output which shows the underlying weblogic.Deployer command that is issued, in which the –userconfigfile and –userkeyfile parameters are used.

    mvn weblogic:list-apps
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building webapp JEE5 Webapp 1.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- weblogic-maven-plugin:12.1.1.0:list-apps (default-cli) @ webapp ---
    weblogic.Deployer invoked with options:  -noexit -adminurl t3://localhost:7001 -userconfigfile /tmp/wls.config -userkeyfile /tmp/wls.key -listapps
    wls-rest
    jersey-bundle [LibSpecVersion=1.1.1,LibImplVersion=1.1.5.1] <ACTIVE VERSION>
    jsr311-api [LibSpecVersion=1.1.1,LibImplVersion=1.1.1] <ACTIVE VERSION>
    ops-ear
    webapp
    jackson-jaxrs [LibSpecVersion=1.0,LibImplVersion=1.1.1] <ACTIVE VERSION>
    jettison [LibSpecVersion=1.1,LibImplVersion=1.1] <ACTIVE VERSION>
    jackson-core-asl [LibSpecVersion=1.0,LibImplVersion=1.1.1] <ACTIVE VERSION>
    jackson-mapper-asl [LibSpecVersion=1.0,LibImplVersion=1.1.1] <ACTIVE VERSION>
    Number of Applications Found : 9
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 6.150s
    [INFO] Finished at: Mon Feb 21 12:31:22 CST 2011
    [INFO] Final Memory: 12M/81M
    [INFO] ------------------------------------------------------------------------
    
    

Deployment Goals

Table C-1 lists all the weblogic-maven-plugin goals.

Table C-1 Maven Plug-In Deployment Goals

Goal Name Description

deploy

Deploys or redeploys an application or module.

undeploy

Stops the deployment and removes staged files from target servers.

redeploy

Redeploys a running application or part of a running application.

start-app

Starts an application.

stop-app

Stops an application.

list-apps

Lists the deployment names for applications and standalone modules deployed, distributed, or installed in the domain.

update-app

Updates an application's deployment plan by redistributing the plan files and reconfiguring the application based on the new plan contents.

help

Lists all the plug-in goals.


deploy

Full Name

com.oracle.weblogic:weblogic-maven-plugin:deploy

Short Name

weblogic:deploy

Description

Deploys an application or module.

Attributes

Requires an application ready for deployment.

Parameters

Table C-2 deploy Parameters

Name Type Default Description

name

String

none

Specifies the deployment name to assign to a newly-deployed application or standalone module. If you do not specify this parameter, WebLogic Server assigns a deployment name to the application, based on its archive file or exploded directory.

source

String

none

Required. Specifies the archive file or exploded archive directory to deploy.

plan

String

none

Specifies the deployment plan to use when deploying the application or module.

targets

String

none

Specifies the targets on which to distribute and deploy the application or module. The value of this parameter is a comma-separated list of target servers, clusters, or virtual hosts.

upload

Boolean

false

When true, copies the source files to the Administration Server's upload directory prior to deployment.

stage

Boolean

false

When true, copies the deployment files to target servers' staging directories.

nostage

Boolean

true

When true, does not copy the deployment files to target servers, but leaves them in a fixed location, specified by the source parameter.

external_stage

Boolean

false

When true, does not copy the deployment files to target servers; instead, you must ensure that deployment files have been copied to the correct subdirectory in the target servers' staging directories. You can manually copy the files or use a third-party tool or script.

You can specify only one of the following parameters: stage, nostage, or external_stage. If none is specified, the default deployment mode to Managed Servers is stage; the default mode to the Administration Server and single server instances is nostage.

retiretimeout

Integer

-1

Specifies the number of seconds before WebLogic Server undeploys the currently-running version of this application or module so that clients can start using the new version.

library

Boolean

false

When true, specifies the deployment as a shared Java EE library or optional package.

libspecver

String

none

Specifies the version of a Java EE library or optional package. You can use this parameter only if the library or package does not include a specification version in its manifest file. libversion can be used only in combination with the library parameter.

libimplver

String

none

Specifies the implementation version of a Java EE library or optional package. You can use this parameter only if the library or package does not include an implementation version in its manifest file. libimplversion can be used only in combination with the library parameter.

usenonexclusivelock

Boolean

false

When true, the deployment operation uses an existing lock, already acquired by the same user, on the domain. This parameter is helpful in environments where multiple deployment tools are used simultaneously and one of the tools has already acquired a lock on the domain configuration.

altappdd

String

none

Specifies the name of an alternative Java EE deployment descriptor (application.xml) to use for deployment.

altwlsappdd

String

none

Specifies the name of an alternative WebLogic Server deployment descriptor (weblogic-application.xml) to use for deployment.

securityModel

String

none

Specifies the security model to use for this deployment. Possible security models are: Deployment descriptors only, Customize roles, Customize roles and policies, Security realm configuration (advanced model). Valid values for this parameter are DDOnly, CustomRoles, CustomRolesAndPolicies, or Advanced.

enableSecuirtyValidation

Boolean

false

When true, enables validation of security data.

id

String

none

Specifies a task identifier of a running deployment task. Make sure that the identifier is unique to all other running deployment tasks. The system automatically generates a unique identifier if you do not specify one.

submoduletargets

String

deploy

Specifies JMS Server targets for resources defined within a JMS application module. The value of this parameter is a comma-separated list of JMS server names. See Using Sub-Module Targeting with JMS Application Modules and Using WLST to Manage JMS Servers and JMS System Resources in Administering JMS Resources for Oracle WebLogic Server.


Usage Example

Example C-5 illustrates using the deploy goal.

Example C-5 deploy

C:\>mvn  com.oracle.weblogic:weblogic-maven-plugin:deploy  
-Dadminurl=t3://myhost:7001 -Duser=weblogic
 -Dpassword=mypassword -Dtargets=AdminServer -Dsource=c:\apps\sample.war
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Mojo Archetype
[INFO]    task-segment: [com.oracle.weblogic:weblogic-maven-plugin:deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [weblogic:deploy {execution: default-cli}]
weblogic.Deployer invoked with options:  -noexit -adminurl t3://myhost:7001
-user weblogic -deploy -source c:\apps\sample.war -targets AdminServer
<Aug 9, 2010 5:54:22 PM PDT> <Info> <J2EE Deployment SPI> <BEA-260121> 
<Initiating deploy operation for application, 
sample.war [archive: c:\apps\sample.war], to Admin Server .>

Task 0 initiated: [Deployer:149026]deploy application sample.war on AdminServer.
 
Task 0 completed: [Deployer:149026]deploy application sample.war on AdminServer.
 
Target state: deploy completed on Server AdminServer
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Mon Aug 09 17:54:23 PDT 2010
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

For additional usage information, see weblogic.Deployer Command-Line Reference.

undeploy

Full Name

com.oracle.weblogic:weblogic-maven-plugin:undeploy

Short Name

weblogic:undeploy

Description

Undeploys an application or module.

Attributes

Requires an already deployed application.

Parameters

Table C-3 undeploy Parameters

Name Type Default Description

name

String

none

Required. Specifies the deployment name of a deployed application or module. If you do not specify this parameter, WebLogic Server assigns a deployment name to the application, based on its archive file or exploded directory.

appversion

String

none

Specifies a version identifier of the deployed application.

planversion

String

none

Specifies a version identifier of the deployment plan.

plan

String

none

Specifies the deployment plan to use when undeploying.

targets

String

none

Specifies the targets from which the application or module are undeployed. The value of this parameter is a comma-separated list of target servers, clusters, or virtual hosts.

retiretimeout

Integer

-1

Specifies the number of seconds before WebLogic Server undeploys the currently-running version of this application or module so that clients can start using the new version.

graceful

String

false

When true, stops the application after existing HTTP clients have completed their work. If you do not specify the graceful parameter, WebLogic Server immediately stops the application or module.

ignoresessions

String

false

When true, immediately places the application into administration mode without waiting for current HTTP sessions to complete.

id

String

none

Specifies a task identifier of a running deployment task. Make sure that the identifier is unique to all other running deployment tasks. The system automatically generates a unique identifier if you do not specify one.

submoduletargets

String

deploy

Specifies JMS Server targets for resources defined within a JMS application module. The value of this parameter is a comma-separated list of JMS server names. See Using Sub-Module Targeting with JMS Application Modules and Using WLST to Manage JMS Servers and JMS System Resources in Administering JMS Resources for Oracle WebLogic Server.


Usage Example

Example C-6 illustrates using the undeploy goal.

Example C-6 undeploy

C:\>mvn  com.oracle.weblogic:weblogic-maven-plugin:undeploy  
-Dadminurl=t3://myhost:7001 -Duser=weblogic
 -Dpassword=mypassword -Dtargets=AdminServer -Dname=sample.war
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Mojo Archetype
[INFO]    task-segment: [com.oracle.weblogic:weblogic-maven-plugin:undeploy]
[INFO] ------------------------------------------------------------------------
[INFO] [weblogic:undeploy {execution: default-cli}]
weblogic.Deployer invoked with options:  -noexit -adminurl t3://myhost:7001
-user weblogic -undeploy -name sample.war -targets AdminServer
<Aug 9, 2010 10:41:16 PM PDT> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiat
ing undeploy operation for application, sample.war [archive: null], 
to AdminServer .>

Task 3 initiated: [Deployer:149026]remove application sample.war on AdminServer.
 
Task 3 completed: [Deployer:149026]remove application sample.war on AdminServer.
 
Target state: undeploy completed on Server AdminServer
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Mon Aug 09 22:41:16 PDT 2010
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

For additional usage information, see weblogic.Deployer Command-Line Reference.

redeploy

Full Name

com.oracle.weblogic:weblogic-maven-plugin:redeploy

Short Name

weblogic:redeploy

Description

Redeploys an application or module.

Attributes

Requires an application ready for deployment.

Parameters

Table C-4 redeploy Parameters

Name Type Default Description

name

String

none

Required. Specifies the deployment name of a deployed application or module. If you do not specify this parameter, WebLogic Server assigns a deployment name to the application, based on its archive file or exploded directory.

If you do not specify the name parameter, you must specify a source.

source

String

none

Specifies the archive file or exploded archive directory to redeploy.

plan

String

none

Specifies the deployment plan to use when redeploying.

targets

String

none

Specifies the targets on which to redeploy the application or module. The value of this parameter is a comma-separated list of target servers, clusters, or virtual hosts.

upload

String

false

When true, copies the source files to the Administration Server's upload directory prior to redeployment.

delete_files

String

false

Removes static files from a server's staging directory. This parameter is valid only for unarchived deployments, and only for applications deployed using stage mode. You must specify target servers when using this parameter.

retiretimeout

Integer

-1

Specifies the number of seconds before WebLogic Server undeploys the currently-running version of this application or module so that clients can start using the new version.

filelist

String

none

Specifies one or more files to redeploy.

id

String

none

Specifies a task identifier of a running deployment task. Make sure that the identifier is unique to all other running deployment tasks. The system automatically generates a unique identifier if you do not specify one.

submoduletargets

String

deploy

Specifies JMS Server targets for resources defined within a JMS application module. The value of this parameter is a comma-separated list of JMS server names. See Using Sub-Module Targeting with JMS Application Modules and Using WLST to Manage JMS Servers and JMS System Resources in Administering JMS Resources for Oracle WebLogic Server.


Usage Example

Example C-7 illustrates using the redeploy goal.

Example C-7 redeploy

C:\>mvn  com.oracle.weblogic:weblogic-maven-plugin:redeploy  
-Dadminurl=t3://myhost:7001 -Duser=weblogic
 -Dpassword=mypassword -Dtargets=AdminServer -Dname=sample.war
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Mojo Archetype
[INFO]    task-segment: [com.oracle.weblogic:weblogic-maven-plugin:redeploy]
[INFO] ------------------------------------------------------------------------
[INFO] [weblogic:redeploy {execution: default-cli}]
weblogic.Deployer invoked with options:  -noexit -adminurl t3://myhost:7001
-user weblogic -redeploy -name sample.war
<Sep 9, 2010 10:12:27 PM PDT> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiat
ing redeploy operation for application, sample.war [archive: null], to to configurd targets.>

Task 1 initiated: [Deployer:149026]redeploy application sample.war on AdminServer.
 
Task 1 completed: [Deployer:149026]redeploy application sample.war on AdminServer.
 
Target state: redeploy completed on ServervE AdminServer
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Sep 09 22:12:27 PDT 2010
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

For additional usage information, see weblogic.Deployer Command-Line Reference.

start-app

Full Name

com.oracle.weblogic:weblogic-maven-plugin:start-app

Short Name

weblogic:start-app

Description

Starts an application.

Attributes

Requires an already deployed application.

Parameters

Table C-5 start-app Parameters

Name Type Default Description

adminmode

Boolean

false

When true, starts an application in administration mode, not production mode (which is the default). Administration mode restricts access to an application to a configured administration channel.

name

String

none

Required. Specifies the deployment name of a deployed application or module to start.

appversion

String

none

Specifies the version of the application to start.

planversion

String

none

Specifies the version of the deployment plan to use when starting the application.

targets

String

none

Specifies the targets on which to start the application or module. The value of this parameter is a comma-separated list of target servers, clusters, or virtual hosts.

retiretimeout

Integer

-1

Specifies the number of seconds before WebLogic Server undeploys the currently-running version of this application or module so that clients can start using the new version.

id

String

none

Specifies a task identifier of a running deployment task. Make sure that the identifier is unique to all other running deployment tasks. The system automatically generates a unique identifier if you do not specify one.

submoduletargets

String

deploy

Specifies JMS Server targets for resources defined within a JMS application module. The value of this parameter is a comma-separated list of JMS server names. See Using Sub-Module Targeting with JMS Application Modules and Using WLST to Manage JMS Servers and JMS System Resources in Administering JMS Resources for Oracle WebLogic Server.


Usage Example

Example C-8 illustrates using the start-app goal.

Example C-8 start-app

C:\>mvn  com.oracle.weblogic:weblogic-maven-plugin:start-app  
-Dadminurl=t3://myhost:7001 -Duser=weblogic
 -Dpassword=mypassword -Dtargets=AdminServer -Dname=sample.war
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Mojo Archetype
[INFO]    task-segment: [com.oracle.weblogic:weblogic-maven-plugin:start-app]
[INFO] ------------------------------------------------------------------------
[INFO] [weblogic:start-app {execution: default-cli}]
weblogic.Deployer invoked with options:  -noexit -adminurl t3://myhost:7001
-user weblogic -start -name sample.war -targets AdminServer
<Aug 9, 2010 10:54:51 PM PDT> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiat
ing start operation for application, sample.war [archive: null], to AdminServer
.>

Task 6 initiated: [Deployer:149026]start application sample.war on AdminServer.
Task 6 completed: [Deployer:149026]start application sample.war on AdminServer.
Target state: start completed on Server AdminServer
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Mon Aug 09 22:54:52 PDT 2010
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

For additional usage information, see weblogic.Deployer Command-Line Reference.

stop-app

Full Name

com.oracle.weblogic:weblogic-maven-plugin:stop-app

Short Name

weblogic:stop-app

Description

Stops an application.

Attributes

Requires an already deployed application.

Parameters

Table C-6 stop-app Parameters

Name Type Default Description

adminmode

Boolean

false

When true, switches the application to administration mode so that it accepts only administration requests via a configured administration channel. If this parameter is not specified, the running application is stopped and cannot accept administration or client requests until is it restarted.

name

String

none

Required. Specifies the deployment name of a deployed application or module to stop.

appversion

String

none

Specifies the version identifier of the deployed application.

planversion

String

none

Specifies the version identifier of the deployment plan.

targets

String

none

Specifies the targets on which to stop the application or module. The value of this parameter is a comma-separated list of target servers, clusters, or virtual hosts.

graceful

Boolean

false

When true, stops the application after existing HTTP clients have completed their work. If you do not specify the graceful parameter, WebLogic Server immediately stops the application or module.

ignoresessions

Boolean

false

When true, immediately places the application into administration mode without waiting for current HTTP sessions to complete.

rmiGraceperiod

Integer

-1

Specifies the amount of time, in seconds, that the Work Manager accepts and schedules RMI calls until there are no more RMI requests arriving within the RMI grace period during a graceful shutdown or a retirement.

retiretimeout

Integer

-1

Specifies the number of seconds before WebLogic Server undeploys the currently-running version of this application or module so that clients can start using the new version.

id

String

none

Specifies a task identifier of a running deployment task. Make sure that the identifier is unique to all other running deployment tasks. The system automatically generates a unique identifier if you do not specify one.

submoduletargets

String

deploy

Specifies JMS Server targets for resources defined within a JMS application module. The value of this parameter is a comma-separated list of JMS server names. See Using Sub-Module Targeting with JMS Application Modules and Using WLST to Manage JMS Servers and JMS System Resources in Administering JMS Resources for Oracle WebLogic Server.


Usage Example

Example C-9 illustrates using the stop-app goal.

Example C-9 stop-app

C:\>mvn  com.oracle.weblogic:weblogic-maven-plugin:stop-app  
-Dadminurl=t3://myhost:7001 -Duser=weblogic
 -Dpassword=mypassword -Dtargets=AdminServer -Dname=sample.war
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Mojo Archetype
[INFO]    task-segment: [com.oracle.weblogic:weblogic-maven-plugin:stop-app]
[INFO] ------------------------------------------------------------------------
[INFO] [weblogic:stop-app {execution: default-cli}]
weblogic.Deployer invoked with options:  -noexit -adminurl t3://myhost:7001
-user weblogic -stop -name sample.war -targets AdminServer
<Aug 9, 2010 10:53:39 PM PDT> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiat
ing stop operation for application, sample.war [archive: null], to AdminServer .
>

Task 5 initiated: [Deployer:149026]stop application sample.war on AdminServer.
Task 5 completed: [Deployer:149026]stop application sample.war on AdminServer.
Target state: stop completed on Server AdminServer
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Mon Aug 09 22:53:39 PDT 2010
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

For additional usage information, see weblogic.Deployer Command-Line Reference.

list-apps

Full Name

com.oracle.weblogic:weblogic-maven-plugin:list-apps

Short Name

weblogic:list-apps

Description

Lists the deployment names for applications and standalone modules deployed, distributed, or installed in the domain.

Attributes

None.

Parameters

There are no parameters required or optionally taken by this goal.

Usage Example

Example C-10 illustrates using the list-apps goal.

Example C-10 list-apps

C:\>mvn  com.oracle.weblogic:weblogic-maven-plugin:list-apps  
-Dadminurl=t3://myhost:7001 -Duser=weblogic
 -Dpassword=mypassword -Dtargets=AdminServer
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Mojo Archetype
[INFO]    task-segment: [com.oracle.weblogic:weblogic-maven-plugin:list-apps]
[INFO] ------------------------------------------------------------------------
[INFO] [weblogic:list-apps {execution: default-cli}]
weblogic.Deployer invoked with options:  -noexit -adminurl t3://myhost:7001
-user weblogic -listapps
 sample.war
Number of Applications Found : 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Mon Aug 09 22:52:07 PDT 2010
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

For additional usage information, see weblogic.Deployer Command-Line Reference.

update-app

Full Name

com.oracle.weblogic:weblogic-maven-plugin:update-app

Short Name

weblogic:update-app

Description

Updates an application's deployment plan by redistributing the plan files and reconfiguring the application based on the new plan contents.

Attributes

Can have an application already deployed.

Parameters

Table C-7 update-app Parameters

Name Type Default Description

name

String

none

Required. Specifies the deployment name of a deployed application or module. If you do not specify this parameter, WebLogic Server assigns a deployment name to the application, based on its archive file or exploded directory.

plan

String

none

Required. Specifies the deployment plan to use for updating the application's configuration. The specified deployment plan must be valid for the application's target servers. For example, the plan cannot contain null variables for required resources unless those resources were previously defined in the associated descriptors.

Update operations update only those descriptors for which there is a changed, not null value in the deployment plan. If a plan that is used by an update operation contains null variables, the current values in the corresponding descriptors are not updated.

planversion

String

none

Specifies the version identifier of the deployment plan.

targets

String

none

Specifies the targets on which to update the application or module. The value of this parameter is a comma-separated list of target servers, clusters, or virtual hosts.

upload

Boolean

false

When true, transfers a new deployment plan to the Administration Server before updating the application.

appversion

String

none

Specifies the version identifier of the deployed application.

id

String

none

Specifies a task identifier of a running deployment task. Make sure that the identifier is unique to all other running deployment tasks. The system automatically generates a unique identifier if you do not specify one.

submoduletargets

String

deploy

Specifies JMS Server targets for resources defined within a JMS application module. The value of this parameter is a comma-separated list of JMS server names. See Using Sub-Module Targeting with JMS Application Modules and Using WLST to Manage JMS Servers and JMS System Resources in Administering JMS Resources for Oracle WebLogic Server.


Usage Example

Example C-11 illustrates using the update-app goal.

Example C-11 update-app

C:\>mvn  com.oracle.weblogic:weblogic-maven-plugin:update-app  
-Dadminurl=t3://myhost:7001 -Duser=weblogic
 -Dpassword=mypassword -Dname=sample.war -Dremote=true
-Dupload=true -Dplan=c:\apps\sampleWar.plan

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Mojo Archetype 12.1.1.0
[INFO] ------------------------------------------------------------------------
[INFO] --- weblogic-maven-plugin:12.1.1.0:update-app (default-cli) 
@ weblogic-maven-plugin ---

weblogic.Deployer invoked with options:  -noexit -adminurl t3://myhost:7001
-user weblogic -update -plan c:\apps\sampleWar.plan sample.war -name sample.war -upload -remote
<Oct 18, 2010 10:30:47 AM PDT> <Info> <J2EE Deployment SPI> <BEA-260121> <Initia
ting update operation for application, sample.war [archive: null], to configured
targets.>

Task 8 initiated: [Deployer:149026]update application sample.war on AdminServer.
Task 8 completed: [Deployer:149026]update application sample.war on AdminServer.
Target state: update completed on Server AdminServer
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.188s
[INFO] Finished at: Mon Oct 18 10:30:49 PDT 2010
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------

For additional usage information, see weblogic.Deployer Command-Line Reference.

help

Full Name

com.oracle.weblogic:weblogic-maven-plugin:help

Short Name

weblogic:help

Description

Lists all the supported deployment goals.

Attributes

  • None.

Usage Example

Example C-12 illustrates using the help goal.

Example C-12 help

C:\>mvn  com.oracle.weblogic:weblogic-maven-plugin:help  
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Mojo Archetype
[INFO] task-segment: [com.oracle.weblogic:weblogic-maven-plugin:help]
 (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [null:help {execution: default-cli} 
The following are the goals available currently in Maven
deploy
list-apps
redeploy
start-app
stop-app
undeploy
update-app
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Oct 05 14:00:01 PDT 2011
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------

Troubleshooting

Table C-8 describes some common Maven plug-in errors and helps you resolve them.

Table C-8 Maven Plug-In Errors

Configuration Step Error Message Resolution

Step 1: Generating the plug-in.

java –jar wljarbuilder.jar –profile weblogic-maven-plugin

Unable to access jarfile wljarbuilder.jar

Make sure that you have issued the command from within the ORACLE_HOME/wlserver/server/lib/ directory.

Step 3: Extracting the pom.xml file from weblogic-maven-plugin.

 

The pom.xml file must be created in a temporary directory (\tmp). For example, c:\tmp\META-INF\maven\com.oracle.weblogic\weblogic-maven-plugin\pom.xml.

Step 4: Provisioning the weblogic-maven-plugin.jar in the Maven repository.

If the provisioning is successful, you will see a Build Successful message.

Build Error

The possible issues are:

Step 5: Executing Maven goals.

If successful, you will see a Build Successful message.

Failed to resolve artifact

The possible issues are:

  • You must run the mvn install command at least once before invoking mvn weblogic:goal. This is required because there are Maven dependencies which must be retrieved from the Internet (see the Note in Step 3 in Configuring and Using the WebLogic Maven Plug-In for Deployment).

  • You have executed the mvn install command from a location other than the temporary directory in which you extracted the pom.xml file.

  • There was no pom.xml file found in the temporary directory into which you copied the weblogic-maven-plugin.jar file and extracted the pom.xml file.

Step 6: Using the shortened name goal invocation of the plug-in.

For example:

$ mvn weblogic:help

Build Failure

[ERROR] Could not find goal 'help' in plugin org.codehaus.mojo:weblogic-maven-plugin:2.9.1 among available goals...

The most likely cause is that you have not followed Step 6 in Configuring and Using the WebLogic Maven Plug-In for Deployment in its entirety.

  • Make sure that you have extracted the pom.xml file and edited it to add the additional <build> stanza:

    <build>
       <plugins>
          <plugin>
           <artifactId>maven-plugin-plugin</artifactId>
           <version>2.3</version>
           <configuration>
             <goalPrefix>weblogic</goalPrefix>
           </configuration>
          </plugin>
        </plugins>
      </build>
    
    
  • Make sure that you have performed the required mvn install after editing the pom.xml file, but before issuing the mvn install:install-file command.

If this error occurs, you can remedy it by simply going back and following Step 6 exactly as written:

  • Extract pom.xml from weblogic-maven-plugin.jar

  • Edit pom.xml to add the <build>...</build> stanza

  • Execute mvn install

  • Execute mvn install:install-file -Dfile=weblogic-maven-plugin.jar -DpomFile=pom.xml