Sunday, October 19, 2014

Weblogic deployment through wldeploy ant task

There are different types and ways to deploy the applications in weblogic .For more information please go through the link. Different Types of Deployments in Weblogic

How to deploy applications with wldeploy ant task in weblogic ?

Weblogic server provides the wldeploy ant task to perform the deployment operations.The wldeploy Ant task  performs weblogic.Deployer functions using attributes specified in an Ant XML file.

How to use the wldeploy ?

To use the wldeploy ant task , ANT should be installed. Refer the link How to install Apache ANT .
  • Verify the ANT installation as below
               -bash-3.2$ ./ant -version
                Apache Ant(TM) version 1.9.4 compiled on April 29 2014
                -bash-3.2$
  • If you get the error JAVA_HOME error as below 
             -bash-3.2$  ./ant -version
             Error: JAVA_HOME is not defined correctly.
             We cannot execute /opt/java/32bit/jdk1.6.0_31/bin/java
  • Set the JAVA_HOME  as below
            -bash-3.2$ export JAVA_HOME=/opt/install/java/32bit/jdk1.6.0_31
            -bash-3.2$ echo $JAVA_HOME
            /opt/install/java//32bit/jdk1.6.0_31
  • Create the build.xml as below
           <project name="weblogic_deployment" default="deploy">
           <target name="deploy">
              <wldeploy
                      action="deploy" verbose="true" debug="true"
                      name="example-App" source="/opt/data/applications/example-App.war"
                      user="weblogic-user" password="weblogic-password"
                      adminurl="t3://weblogic-admin-host:7001" targets="server-name"  />
              </target>
             </project>
  •  Set the weblogic environment variables , otherwise will get the below type of error.
    -bash-3.2$ ./ant deploy
        Buildfile: /opt/data/ant/apache-ant-1.9.4/bin/build.xml
       deploy:
       BUILD FAILED
       /opt/data/ant/apache-ant-1.9.4/bin/build.xml:8: Problem: failed to create task or type wldeploy
       Cause: The name is undefined.
       Action: Check the spelling.
       Action: Check that any custom tasks/types have been declared.
       Action: Check that any <presetdef>/<macrodef> declarations have taken place.
       Total time: 0 seconds
  • Set the weblogic domain environment variables as below 
          -bash-3.2$ . /opt/weblogic/domain/weblogicdomain/bin/setDomainEnv.sh
           Note: Here /opt/weblogic/domain/weblogicdomain is weblogic domain home
  • Run the ant script as 
           -bash-3.2$ ./ant deploy

Issues we may get during the deployment through wldeploy ant task

BUILD FAILED
weblogic.management.ManagementException: [Deployer:149163]The domain edit lock is owned by another session in non-exclusive mode - this deployment operation requires exclusive access to the edit lock and hence cannot proceed. If you are using "Automatically Aquire Lock and Activate Changes" in the console, then the lock will expire shortly so retry this operation.

Solution 2 : Wait until Lock& Edit available or release the Configuration changes to obtain the lock.

Solution 2 : use the usenonexclusivelock="true" to build.xml to avoid the error.

Note: If we use this option  ant will not through error but gives the warning as 
[wldeploy] [BasicOperation.execute():445] : Initiating deploy operation for app, example-App , on targets:
 [wldeploy] [BasicOperation.execute():447] :    server-name
 [wldeploy] Task 14 initiated: [Deployer:149026]deploy application example-App on server-name.
 [wldeploy] Operation is pending and will be activated or cancelled when the ongoing edit session is activated or cancelled.
  • Once the activate changes done deployment done other wise changes will not reflect.




5 comments:

  1. Below Lines are required to be declared before defining any target in build.xml, it will prevent in throwing error like:
    /opt/data/ant/apache-ant-1.9.4/bin/build.xml:8: Problem: failed to create task or type wldeploy
    Cause: The name is undefined.
    Action: Check the spelling.
    Action: Check that any custom tasks/types have been declared.
    Action: Check that any / declarations have taken place.


    Lines are:

    ReplyDelete
  2. What are the lines?

    ReplyDelete