Thursday, October 21, 2010

Working with Ant script in SOA Suite 11g

The various ant script available in SOA suite 11g can be found in the following location

Middleware_Home\SOA_Server1\bin

We have different xml file to compile, deploy retire upgrade and many more options

For additional information on ant you can go to following http://ant.apache.org


OK i have created a simple process in jdeveloper 11g and and will try to deploy it using command console.

Open up a command console and move to SOA_HOME\bin directoy

First of all we will check by compiling the project if everything is working fine.

I executed the compilation command and it got failed for me with error

D:\oracle\Middleware\Oracle_SOA1\bin>ant -f ant-sca-compile.xml -Dscac.input=C:\
JDeveloper\mywork\arpit\QueryDatabase\composite.xml
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.6.
0_07\lib\tools.jar
Buildfile: ant-sca-compile.xml

scac:
[scac] Validating composite : 'C:\JDeveloper\mywork\arpit\QueryDatabase\com
posite.xml'

BUILD FAILED
D:\oracle\Middleware\Oracle_SOA1\bin\ant-sca-compile.xml:264: Java returned: 1 C
heck log file : C:\DOCUME~1\arahi\LOCALS~1\Temp\/out.err for errors

Total time: 8 seconds




so the reason was my java home was not set properly

i did set it to my middleware jdk

This i done intentionally

Baiscally we need to set three important parameters before we could just run the ant command

1>JAVA_HOME
2>ORACLE_HOME and
3>ANT_HOME


so i ran three command to set it


D:\oracle\Middleware\Oracle_SOA1\bin>set JAVA_HOME=D:\oracle\Middleware\jdk160_1
4_R27.6.5-32

D:\oracle\Middleware\Oracle_SOA1\bin>set ORACLE_HOME=D:\oracle\Middleware\Oracle
_SOA1

D:\oracle\Middleware\Oracle_SOA1\bin>set ANT_HOME=D:\oracle\Middleware\modules\o
rg.apache.ant_1.7.0


now i will run the compile command again

and this time it ran successfully for me





Now we will try to deploy this project,as you can see in the Oracle documentation to deploy a process it needs the sar location.


So first of all we will create a sar file out of our project file.

This can be done from jdeveloper.

Select your process and say deploy





when option will come just choose deploy to SAR



Provide the version number and say finish to deploy it





YOu can see in the jdeveloper where is the .jar file created,by default it is created in the location where project is stored and within that deploy folder so for my case it was stored in following location

C:\JDeveloper\mywork\arpit\QueryDatabase\deploy\sca_QueryDatabase_rev1.0.jar


Ok just to let you know if you have this jar file you can directly go to your em console and deploy this project.


For that purpose just log in to em console

Right click on SOA_Infra

then click on SOA Deployment and click on deploy when new page comes just locate the .jar file thus created and keep on saying next and your process will be deployed.

However in this post we are discussing about deploying a file using ant script so we will go ahead with that.

So i post the following command now and for me it deployed successfully

D:\oracle\Middleware\Oracle_SOA1\bin>ant -f ant-sca-deploy.xml -DserverURL=http:
//localhost:8001 -DsarLocation=C:\JDeveloper\mywork\arpit\QueryDatabase\deploy\s
ca_QueryDatabase_rev2.0.jar -Doverwrite=true -Duser=weblogic
Buildfile: ant-sca-deploy.xml
[echo] oracle.home = D:\oracle\Middleware\Oracle_SOA1\bin/..

deploy:
[input] skipping input as property serverURL has already been set.
[input] skipping input as property sarLocation has already been set.
[deployComposite] Processing sar=C:\JDeveloper\mywork\arpit\QueryDatabase\deploy
\sca_QueryDatabase_rev2.0.jar
[deployComposite] Adding sar file - C:\JDeveloper\mywork\arpit\QueryDatabase\dep
loy\sca_QueryDatabase_rev2.0.jar
[deployComposite] Creating HTTP connection to host:localhost, port:8001
[deployComposite] Enter username and password for realm 'default' on host localh
ost:8001
[deployComposite] Authentication Scheme: Basic
[deployComposite] Username:
weblogic
[deployComposite] Password:

[deployComposite] Received HTTP response from the server, response code=200
[deployComposite] ---->Deploying composite success.


YOu will be once asked to provide the user and password for weblogic server once you will provide that it will go ahead and deploy your process to the server ,you can make changes in the project by referring to different configuration plan.

No comments: