Pillai’s

Technology and Everything…..

Deploying Oracle BPEL Process to Different Instances Using ANT and Parmeters

Posted by Shibu on December 18, 2007

If you are a Oracle SOA Developer, I am sure you will be using Oracle Jdeveloper for the development of BPEL process. In this Blog I will show you how you can build and deploy your BPEL process from command line using ant. Also I will explain you how you can pass parameters while compiling, so that you can deploy to different servers by using server name as parameter. Also I have used parmater to specify directory locations for the file adpaters used in the BPEL process.

This blog assumes that you already installed JDeveloper and created a BPEL process and deployed to development server using JDevloper.

Open command window by running cmd command. Find out where you have installed your JDeveloper. In my case I have installed it in the D:\jdev10132 directory. This is going to be your ORACLE_HOME. Issue following command from the command window.

SET ORACLE_HOME=d:\jdev10132 (This should be your directory where you installed JDeveloper)

Now make sure the command worked by issuing echo %ORACLE_HOME%

Next you have to set ANT_HOME variable. Issue following command,

SET ANT_HOME=d:\jdev10132\ant

Now you have to include ant in the PATH. Issue following command,

SET PATH=d:\jdev10132\ant\bin;%PATH%

Now type ant you should get message like below
Buildfile: build.xml does not exit!
Build Failed.

(Of course if you have build.xml file in the directory where you are now, ant will try to compile the default target mentioned in the build file and you may get different message)

Next we have to make sure we have all jar files in the ant lib directory. Go to ANT_HOME\lib directory. You should see many jar files in this directory. I am attaching the screen print of the files which I have in my lib directory.

Next we have to make sure we have all jar file in the bpel lib directory. Go to your ORACLE_HOME. In my case it is d:\jdev10132. Next go to integration\bpel\lib directory. Here you should have many files. In my case I had only one jar file here. I will explain you how you can get all required files. If you have already installed BPEL Server then you may have all files. Required files are orabpel-ant.jar, orabpel.jar, orabpel-boot.jar, orabpel-common.jar, orabpel-exts.jar, orabpel-thirdparty.jar, oracle_http_client.jar.

If you do not have these file you can download these jar files from the server if it is installed in different machine. In my case we have our SOA server installed in a linux machine. We installed our SOA server in /d01/orsoa directory. So all the jar files for bpel are in /d01/orsoa/10.1.3/bpel/lib directory. I downloaded all jar files from this directory to the ORACLE_HOME\integration\bpel\lib directory.

Now you have finished all pre-requisite steps.

Find out the directory where you have your application/project saved from JDeveloper. In my case my project files are in the directory d:\oaframework\jdevhome\jdev\mywork\BPELExample\BPELProcess1 directory. BPELProcess1 is my BPEL process name.

So find out where you have saved your BPEL project and cd to that directory in the command window. Just list all files using DIR command. You should see a build.xml file which is created by JDeveloper.

Now we will prepare for our deployment using ant.

As I mentioned before I have a file adapter in my BPEL process which reads file and archives it too. For different servers, the physical directory location is different. So while deploying I want to make the directory location as parameter so that DBA who will deploy to production server will change it accordingly. I will show how we can achieve this.

In Oracle JDeveloper when defining a file adapter you have mention the location of files where it reads from or write to. If you have a file adapter open the file adapter wizard and go to the step where you define the file location. If you notice there is an option “Directory Names are Specified as Physical Path or Logical Name. Choose Logical Name here. In my case I have mentioned input file location as “indir” and archive file location as “archdir”. Choose appropriate names for your case and save all files. Build from JDeveloper.

Now that you have mentioned logical name for your directory, you have to mention the mapping to physical path somewhere right? Oh yeah, let us do that. Go to your project home directory. In my case it is d:\oaframework\…\BPELProcess1. Under this you should see another directory bpel. Open the file bpel.xml in this directory and search for the logical name you used. I will see like below,

JDeveloper created these two for you. We have to mention the physical path here as value. What we will do is introduce two variables here instead of values. These variables can be passed as parameters while compiling using ant. So DBA can supply file location as parameters while compiling and deploying. So I modified these two lines like below,

@@archdir@@
@@indir@@

Save this file.

Navigate one directory above to your project home directory. Here you should have build.xml file.

Create a new file pre-build.xml file in this directory. When you use ant to compile it will first process commands written in this file. We will replace our variables in the pre-build process. So create pre-build.xml file like below,

<?xml version = ‘1.0’ encoding = ‘UTF-8’?>
<project name=”bpel.deploy” basedir=”.”>
<property name=”process.dir” value=”${basedir}”/>
<copy file=”${basedir}\bpel\bpel.xml” tofile=”${basedir}\bpel\bpel.xml.orig”/>
<replaceregexp file=”${basedir}\bpel\bpel.xml” match=”@@archdir@@” replace=”${archdir}” />
<replaceregexp file=”${basedir}\bpel\bpel.xml” match=”@@indir@@” replace=”${indir}” />
</project>

As you can see I am replacing the @@archdir@@ using the parameter archdir. Parameter can be accessed using syntax ${ }

Also you might have noticed that I am copying bpel.xml file to bpel.xml.orig. This is because when you deploy using ant command bpel.xml file will be changed. @@@@ will be replaced with the value passed as parameter. So when you try to compile/deploy second time ant will not able to replace as there will not be any @@@@ in the bpel.xml file !!

Now we will create another file post-build.xml file. In this file we will copy the bpel.xml.orig file back to bpel.xml as below,

<?xml version = ‘1.0’ encoding = ‘UTF-8’?>
<project name=”bpel.deploy” basedir=”.”>
<property name=”process.dir” value=”${basedir}”/>
<copy file=”${basedir}\bpel\bpel.xml.orig” tofile=”${basedir}\bpel\bpel.xml”/>
</project>

So far we have parameterized directory location for the file adapter. Now another variables needed are server name, port, user name and password. All these will vary from instance to instance. So we have to provide flexibility to DBA to change these during deploying. We will make all these parameters.

Open the file build.properties. Here is where you will mention all these variables.

Uncomment and update following lines like below,

admin.user=${adminuser}
admin.password=${adminpass}
http.hostname=${dephost}
http.port=${depport}

Alright, you have finished all steps for deployment ….Ready? Ok, deploy using command

ant –Dadminuser=administrator –Dadminpass=your_password -Ddephost=your_host_name
-Ddepport=your_port_address -Darchdir=physical_location_of_archiving
-Dindir=physical_location_of_input_directory

If everything done as mentioned, you should be able to deploy your process !!!

Advertisements

2 Responses to “Deploying Oracle BPEL Process to Different Instances Using ANT and Parmeters”

  1. Nuno Pereira said

    Hi there,

    When I saw your post I thought “All my problems will vanish” but then I got this:
    “Exception not handled by the Collaxa Cube system.
    An unhandled exception has been thrown in the Collaxa Cube system. The exception
    reported is: “java.lang.NoClassDefFoundError: sun/tools/javac/Main
    at com.collaxa.cube.util.JavaHelper.javac(JavaHelper.java:203)”

    Do you have any idea why I got this? I did not create a pre-build file as i did not have an adapter.

    Any help would be most welcome.

    Thanks,
    Nuno Pereira

  2. Shibu Pillai said

    Hi Nuno,
    I am not sure exact reason, unless I get all details step by step. Did you copy all JAR files into the ANT_HOME/lib directory?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: