OSB 11g ANT deployment scripts

Bookmark and Share
For Oracle Service Bus 10.3 & 11g you can use the ANT / WLST deployment scripts provided by Oracle. With these scripts you can make an export of a project from sbconsole and make a deployment / configuration plan and you can import a project jar to the sbconsole.



I made some changes to these scripts so it only needs one property file, you don't need the import or export.properties files. The second change I made is support for making an export jar from the OSB workspace ( OEPE environment ). Very important to do this on a copy of your workspace or use subversion because you need to delete the .metadata folder for a successful export. ( you will loose all your workspace settings )

Here is the build.properties

fmw.home=C:/oracle/Soa11gPS2

wls.username      = weblogic
wls.password      = weblogic1
wls.server        = t3://localhost:7001

# properties for workspace export
config.project="OSB Configuration"
config.jar=c:/temp/sbconfig.jar
config.subprojects="EJB,Rest"
config.includeDependencies=true
workspace.dir=C:/projecten/workspace/osb11g3

# export properties

# specify a project or use None
#export.project    = EJB
export.project    = None
export.jar        = c:/temp/export.jar
#export.customFile = c:/temp/cust.xml
export.customFile = None

# import properties

# specify a project or use None
import.project    = None
#import.project    = EJB
import.jar        = c:/temp/export.jar
#import.customFile = None
import.customFile = "c:/temp/cust.xml



The ANT build.xml

<?xml version="1.0" encoding="windows-1252" ?>
<project name="ConfigExport">

<property file="./build.properties"/>

<property name="eclipse.home" value="${fmw.home}/oepe_11gR1PS2"/>
<property name="weblogic.home" value="${fmw.home}/wlserver_10.3"/>
<property name="metadata.dir" value="${workspace.dir}/.metadata"/>
<property name="osb.home" value="${fmw.home}/Oracle_OSB1"/>

<property name="domain.export.script" value="export.py" />
<property name="domain.import.script" value="import.py" />

<target name="exportFromOSB">
<wlst fileName="${domain.export.script}" debug="true" failOnError="false"  
arguments="${wls.username} ${wls.password} ${wls.server} ${export.project} ${export.jar} ${export.customFile}">  
<script>  
adminUser=sys.argv[1]  
adminPassword=sys.argv[2]  
adminUrl=sys.argv[3]

exportJar = sys.argv[5]
customFile = sys.argv[6]
passphrase = "osb"
project = sys.argv[4]

connect(adminUser,adminPassword,adminUrl) 
domainRuntime()
</script>
</wlst>
</target>

<target name="importToOSB">
<wlst fileName="${domain.import.script}" debug="true" failOnError="false"  
arguments="${wls.username} ${wls.password} ${wls.server} ${import.project} ${import.jar} ${import.customFile}">  
<script>  
adminUser=sys.argv[1]  
adminPassword=sys.argv[2]  
adminUrl=sys.argv[3]

passphrase = "osb"

project=sys.argv[4]
importJar=sys.argv[5]
customFile=sys.argv[6]

connect(adminUser,adminPassword,adminUrl) 
domainRuntime()
</script>
</wlst>
</target>

<target name="exportFromWorkspace">
<delete failonerror="false" includeemptydirs="true"
dir="${metadata.dir}"/>
<java dir="${eclipse.home}"
jar="${eclipse.home}/plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar"
fork="true" failonerror="true" maxmemory="768m">
<jvmarg line="-XX:MaxPermSize=256m"/>   
<arg line="-data ${workspace.dir}"/>
<arg line="-application com.bea.alsb.core.ConfigExport"/>
<arg line="-configProject ${config.project}"/>
<arg line="-configJar ${config.jar}"/>
<arg line="-configSubProjects ${config.subprojects}"/>
<arg line="-includeDependencies ${config.includeDependencies}"/>
<sysproperty key="weblogic.home" value="${weblogic.home}"/>
<sysproperty key="osb.home" value="${osb.home}"/>
<sysproperty key="osgi.bundlefile.limit" value="500"/>
<sysproperty key="harvester.home" value="${osb.home}/harvester"/>
<sysproperty key="osgi.nl" value="en_US"/>
<sysproperty key="sun.lang.ClassLoader.allowArraySyntax" value="true"/>
</java>
</target>


</project>


When you want to run the ANT task from CMD then you need these environment variables

set FMW_HOME=C:\oracle\Soa11gPS2
set ANT_HOME=%FMW_HOME%\modules\org.apache.ant_1.7.1
set PATH=%ANT_HOME%\bin;%PATH%
set JAVA_HOME=%FMW_HOME%\jdk160_18
set CLASSPATH=%FMW_HOME%/wlserver_10.3/server/lib/weblogic.jar;%FMW_HOME%/Oracle_OSB1/lib/alsb.jar;%FMW_HOME%/Oracle_OSB1/modules/com.bea.common.configfwk_1.3.0.0.jar


You can use these ANT tasks

ant exportFromWorkspace ( do this on a copy of your OEPE workspace )

ant importToOSB

ant exportFromOSB



Or you can run these task in JDeveloper then you need to update these classpath entries for ANT

And run your ANT task from JDeveloper.

{ 0 comments... Views All / Send Comment! }

Post a Comment