Friday, 31 May 2013

Ant script deployment for BPEL


In this tutorial I will explain how BPEL interfaces can deploy in unix environment using shell script.
But before that you need to set all the path.



Create on setWLSEnv.cmd file where set all the path or individually set all these path in comment promt.

set ORACLE_HOME=C:\oracle\Middleware
set ANT_HOME=%ORACLE_HOME%\jdeveloper\ant
set PATH=%ANT_HOME%\bin;%PATH%
set JAVA_HOME=%ORACLE_HOME%\jdk160_24


after setting path echo the path.

Now back to the command prompt.
Check ant exists or not

But if you want to permanently set the path ,use environment variable to set it

A sample project has been to created to print an input message from a Asynchronous BPEL. The user gives input through the client.

Before deployment I can configure a deployment plan xml file.
Right Click on composite.xml file and Generate config plan.

Appending env name:dev
A file generates name <projectName_cfgPlan_env.xml>.

Env may be dev,test,prod according to your need.

This configuration can be attached at the time of deployment. You can change properties of the project with the configuration plan.

Add two files (build.properties, build.xml) in the same project of the JDeveloper (.Jca Project).
Sample files is given with the document.


build.properties
build .properties file contain all the environment related path and port details.
There should be one build .properties for each environment.Here  

# build file for HelloWorldComposite
proj.composite.name=HelloWorld
# revision of the composite
proj.composite.revision=1.0
# Simply specify Java Home
java.home =C:/Oracle/Middleware/jdk160_18/bin
#Project directory
proj.compositeDir=C:/JDeveloper/mywork/HelloApps/HelloWorld
# Set oracle.home to <JDEV_HOME>/jdeveloper, where <JDEV_HOME> is JDEV # installation directory
oracle.home=C:/Oracle/Middleware/jdeveloper
# soa-server side oracle home directory - needed for deployment plans
# and the weblogic sca library deployment
soa.server.oracle.home=C:/Oracle/Middleware/Oracle_SOA1
#################Deployment server connection information########################
# the admin server connection information
admin.server.host=localhost
admin.server.port=7001
# the domain where soa infra is installed
server.domain.name=soa_domain
# connection information for the managed server, used for soa-deployment
managed.server.host=localhost
managed.server.port=8001
# User and credentials for the servers
server.user=weblogic
server.password=Welcome1
# wls server where soa is targeted.
server.targets=soa_server1
deployment.plan.environment=dev

build.xml

<?xml version="1.0" encoding="UTF-8" ?>
<project name="SoaWSProject">
  <!-- build.properties --> 
   <property file="build.properties"/>
  <property name="deploy.dir" value="${proj.compositeDir}/deploy"/>
  <echo>deploy.dir :${deploy.dir}</echo>
   <target name="build">
    <property name="sca-inf.classes.dir" value="../SCA-INF/classes"/>
       <mkdir dir="${sca-inf.classes.dir}"/>
      <ant antfile="${oracle.home}/bin/ant-sca-package.xml" target="package" inheritall="false">
        <property name="oracle.home" value="${oracle.home}"/>
        <property name="compositeDir" value="${proj.compositeDir}"/>
               <!-- needed for adf config -->
         <property name="scac.application.home" value="${basedir}/../.."/>
         <!-- name of the composite -->
        <property name="compositeName" value="${proj.composite.name}"/>
         <!-- revision of the composite -->
        <property name="revision" value="${composite.revision}"/>
         <!-- java.passed.home passed to scac, this property will be
             overwritten to the env.JAVA_HOME if such env variable is defined in OS level-->
         <property name="java.passed.home" value="${java.home}"/>
    </ant>
  </target>
  <target name="deploy">
     <echo>Deploying to http://${managed.server.host}:${managed.server.port}/soa-infra/deployer</echo>
     <echo>proj.compositeDir :$(proj.compositeDir)</echo>
            <echo>composite.name :${composite.name}</echo>
            <echo>java.home :${java.home}</echo>
            <echo>deploy.dir :${deploy.dir}</echo>
    <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" target="deploy" inheritall="false">
        <!-- reformat of prop names -->
         <property name="user" value="${server.user}"/>
        <property name="password" value="${server.password}"/>
        <!-- create the url for deployment -->
        <property name="serverURL" value="http://${managed.server.host}:${managed.server.port}/soa-infra/deployer"/>
         <!-- location of the sar -->
        <property name="sarLocation" value="${deploy.dir}/sca_${proj.composite.name}_rev${composite.revision}.jar"/>
         <!-- force overwrite if already there -->
        <property name="overwrite" value="true"/>
        <property name="forceDefault" value="true"/>
         <!-- configplan-->
        <property name="configplan" value="${proj.compositeDir}/${proj.composite.name}_cfgplan_${deployment.plan.environment}.xml"/>
    </ant>
<echo>sarLocation :${sarLocation}</echo>
 </target> 
</project>

Now run the build.xml file to build the project.I am using "ant build" commend.Here is build
After compilation you have to deploy the project




2 comments:

  1. Hi Team,
    Could you please provide me the code to save the SAR file with latest timestamp in same buidl.xml.

    ReplyDelete
  2. I wish to show thanks to you just for bailing me out of this particular trouble. As a result of checking through the net and meeting techniques that were not productive, Same as your blog I found another one Oracle OSB 12c.Actually I was looking for the same information on internet for Oracle OSB 12c and came across your blog. I am impressed by the information that you have on this blog. Thanks once more for all the details.

    ReplyDelete