C Using the WebLogic Maven Plug-In for Deployment

This appendix describes how to use the WebLogic Maven plug-in. Apache Maven is a software tool for building and managing Java-based projects. Now you can use a Maven plug-in for WebLogic Server 10.3.6 (weblogic-maven-plugin) to perform deployment operations similar to those supported by the command-line utility, weblogic.Deployer. The plug-in lets you deploy, redeploy, update, and such, applications built using Maven to WebLogic Server 10.3.6 from within the Maven environment. The weblogic-maven-plugin works with Maven 2.x and 3.x.

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.

This appendix includes the following sections:

Configuring and Using the WebLogic Maven Plug-In

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 MW_HOME/wlserver_10.3/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=10.3.6.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.
  2. Extract the pom.xml file from weblogic-maven-plugin.jar under the MW_HOME/wlserver_10.3/server/lib directory, and then copy the pom.xml file to MW_HOME/wlserver_10.3/server/lib.

    For example:

    jar xvf MW_HOME/wlserver_10.3/server/lib/weblogic-maven-plugin.jar 
    META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml
    
    cp MW_HOME/wlserver_10.3/server/lib/META-INF/maven/com.oracle.weblogic/
    weblogic-maven-plugin/pom.xml MW_HOME/wlserver_10.3/server/lib
    
  3. 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 5 before performing this step.

    mvn install:install-file 
    -Dfile=MW_HOME/wlserver_10.3/server/lib/weblogic-maven-plugin.jar -DpomFile=pom.xml
    

    Typical command output is like the following:

    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'install'.
    [INFO] com.oracle.weblogic: checking for updates from central
    [INFO] org.apache.maven.plugins: checking for updates from central
    [INFO] org.codehaus.mojo: checking for updates from central
    Downloading:
    http://repo1.maven.org/maven2/org/apache/maven/plugins/
    maven-install-plugin/2.2/maven-install-plugin-2.2.pom
    Downloading:
    ...
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Maven Mojo Archetype
    [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
    ....
    [INFO] [install:install-file {execution: default-cli}]
    [INFO] Installing c:\Oracle\Middleware\wlserver_10.3\
    server\lib\weblogic-maven-plugin.jar to 
    C:\depot\.m2\repository\com\oracle\weblogic\weblogic-maven-plugin\10.3.6.0\
    weblogic-maven-plugin-10.3.6.0.jar
    [INFO] Installing C:\Oracle\Middleware\wlserver_10.3\server\lib\pom.xml to C:\depot\.m2\repository\com\oracle\weblogic\weblogic-maven-plugin\10.3.6.0\
    weblogic-maven-plugin-10.3.6.0.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 24 seconds
    [INFO] Finished at: Wed Oct 05 13:48:10 PDT 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.
  4. 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 5):

      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>10.3.6.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> 
      
  5. 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 MW_HOME/wlserver_10.3/server/lib/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>10.3.6.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 MW_HOME/wlserver_10.3/server/lib/, run the mvn install command.

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

      mvn install
      
    4. From within MW_HOME/wlserver_10.3/server/lib/, provision the weblogic-maven-plugin.jar in your local Maven repository, as follows:

      mvn install:install-file 
      -Dfile=MW_HOME/wlserver_10.3/server/lib/weblogic-maven-plugin.jar -DpomFile=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 Oracle WebLogic Scripting Tool and "User Credentials Arguments" in the weblogic.Deployer Command-Line Reference.

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','welcome1')
    wls:/mydomain/serverConfig>storeUserConfig(&rsquor;/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, <MW_HOME>/modules/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 <MW_HOME>
      cd modules
      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 and 2 in Configuring and Using the WebLogic Maven Plug-In.

    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>10.3.6.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>10.3.6.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 weblogic:list-apps goal—This goal doesn't 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:10.3.6.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 the weblogic-maven-plugin deployment goals.

Table C-1 Maven Plug-In Deployment Goals

Short Name Description

weblogic:deploy

Deploys or redeploys an application or module.

weblogic:undeploy

Stops the deployment and removes staged files from target servers.

weblogic:redeploy

Redeploys a running application or part of a running application.

weblogic:start-app

Starts an application.

weblogic:stop-app

Stops an application.

weblogic:list-apps

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

weblogic:update-app

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

weblogic:help

Lists all the deployment goals.


weblogic.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 weblogic:deploy Parameters

Option Type Default Description

name

String

none

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

source

String

none

Required. Archived file or exploded archive directory to deploy.

plan

String

none

Deployment plan to use when deploying the application or module.

targets

String

none

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

upload

Boolean

false

Copies the source files to the Administration Server's upload directory prior to deployment.

stage

Boolean

false

Copies deployment files to target servers' staging directories.

nostage

Boolean

true

Does not copy the deployment files to target servers, but leaves them in a fixed location, specified by the source option.

external_stage

Boolean

false

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 attributes: 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

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

The deployment as a shared Java EE library or optional package.

libspecver

String

none

Specification version of a Java EE library or optional package. You can use this option 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 attribute.

libimplver

String

none

Implementation version of a Java EE library or optional package. You can use this option 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 attribute.

usenonexclusivelock

Boolean

false

Deployment operation uses an existing lock, already acquired by the same user, on the domain. This option 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

Name of an alternate Java EE deployment descriptor (application.xml) to use for deployment.

altwlsappdd

String

none

Name of an alternate WebLogic Server deployment descriptor (weblogic-application.xml) to use for deployment.

securityModel

String

none

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). Actual valid values for this attribute are DDOnly, CustomRoles, CustomRolesAndPolicy, or Advanced.

enableSecurityValidation

Boolean

false

Enable validation of security data.

id

String

none

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

JMS Server targets for resources defined within a JMS application module. The value of this attribute 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 Configuring and Managing JMS for Oracle WebLogic Server.


Example

Example C-5 illustrates using the weblogic:deploy goal.

Example C-5 weblogic: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.

weblogic: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 weblogic:undeploy Parameters

Option Type Default Description

name

String

none

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

appversion

String

none

Version identifier of the deployed application.

planversion

String

none

Version identifier of the deployment plan.

plan

String

none

Deployment plan to use when undeploying.

targets

String

none

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

retiretimeout

Integer

-1

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

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

ignoresessions

String

false

Immediately places the application into Administration mode without waiting for current HTTP sessions to complete.

id

String

none

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

JMS Server targets for resources defined within a JMS application module. The value of this attribute 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 Configuring and Managing JMS for Oracle WebLogic Server.


Example

Example C-6 illustrates using the weblogic:undeploy goal.

Example C-6 weblogic: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.

weblogic: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 weblogic:redeploy Parameters

Option Type Default Description

name

String

none

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

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

source

String

none

Archive file or exploded archive directory to redeploy.

plan

String

none

Deployment plan to use when redeploying.

targets

String

none

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

upload

String

false

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 attribute is valid only for unarchived deployments, and only for applications deployed using stage mode. You must specify target servers when using this attribute.

retiretimeout

Integer

-1

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

One or more files to redeploy.

id

String

none

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

JMS Server targets for resources defined within a JMS application module. The value of this attribute 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 Configuring and Managing JMS for Oracle WebLogic Server.


Example

Example C-7 illustrates using the weblogic:redeploy goal.

Example C-7 weblogic: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.

weblogic: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 weblogic:start-app Parameters

Option Type Default Description

adminmode

Boolean

false

Start 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. Deployment name of a deployed application or module to start.

appversion

String

none

Version of the application to start.

planversion

String

none

Version of the deployment plan to use when starting the application.

targets

String

none

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

retiretimeout

Integer

-1

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

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

JMS Server targets for resources defined within a JMS application module. The value of this attribute 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 Configuring and Managing JMS for Oracle WebLogic Server.


Example

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

Example C-8 weblogic: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.

weblogic: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 weblogic:stop-app Parameters

Option Type Default Description

adminmode

Boolean

false

Indicates that a running application should switch to Administration mode and accept only Administration requests via a configured Administration channel. If this option is not specified, the running application is stopped and cannot accept Administration or client requests until is it restarted.

name

String

none

Required. Deployment name of a deployed application or module to stop.

appversion

String

none

Version identifier of the deployed application.

planversion

String

none

Version identifier of the deployment plan.

targets

String

none

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

graceful

Boolean

false

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

ignoresessions

Boolean

false

Immediately places the application into Administration mode without waiting for current HTTP sessions to complete.

rmiGraceperiod

Integer

-1

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

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

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

JMS Server targets for resources defined within a JMS application module. The value of this attribute 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 Configuring and Managing JMS for Oracle WebLogic Server.


Example

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

Example C-9 weblogic: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.

weblogic: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.

Parameters

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

Example

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

Example C-10 weblogic: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.

weblogic: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 weblogic:update-app Parameters

Option Type Default Description

name

String

none

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

plan

String

none

Required. 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

Version identifier of the deployment plan.

targets

String

none

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

upload

Boolean

false

Transfers a new deployment plan to the Administration Server before updating the application.

appversion

String

none

Version identifier of the deployed application.

id

String

none

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

JMS Server targets for resources defined within a JMS application module. The value of this attribute 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 Configuring and Managing JMS for Oracle WebLogic Server.


Example

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

Example C-11 weblogic: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 10.3.6.0
[INFO] ------------------------------------------------------------------------
[INFO] --- weblogic-maven-plugin:10.3.6.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.

weblogic:help

Full Name

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

Short Name

weblogic:help

Description

Lists all the supported deployment goals.

Example

Example C-12 illustrates using the weblogic:help goal.

Example C-12 weblogic: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 MW_HOME/wlserver_10.3/server/lib/ directory.

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

 

The pom.xml file is created in MW_HOME/wlserver_10.3/server/lib/META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml. From this location, you must copy the pom.xml file to MW_HOME/wlserver_10.3/server/lib/ (see Step 2 in Configuring and Using the WebLogic Maven Plug-In).

Step 3: 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 4: 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).

  • You have executed the mvn install command from a location other than MW_HOME/wlserver_10.3/server/lib/.

  • There was no pom.xml file found under MW_HOME/wlserver_10.3/server/lib/.

Step 5: 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 5 in Configuring and Using the WebLogic Maven Plug-In 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 5 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