Sunday, January 08, 2012

Export/Import OSB Projects using WLST with Apache Ant - OSB 11g

In this post, we are going to export and import (deploy) OSB projects. Oracle has provided some standardized Python (infact Jython - the java version of Python) scripts which will be processed by  WebLogic Scripting Tool (WLST). So, lets go straight into "how-to" of doing things.

We are going wrap the WLST scripts from ANT tasks using weblogic server provided <wlst> tag for Ant. And our WLST is going to process the import (import.py) and export (export.py) scripts.

1. Set JAVA_HOME
JAVA_HOME= <location of java home>
export JAVA_HOME
echo $JAVA_HOME

2. Set CLASSPATH. CLASSPATH variable should contain weblogic.jar, alsb.jar and com.bea.common.configfwk_1.3.0.0.jar .
FMW_HOME=/u01/app/oracle/product/fmw
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
export CLASSPATH
echo $CLASSPATH

[Note: mutiple paths are seperated by colon(:) in Unix]

3. Now, place the 4 files (build.xml, build.properties, export.py and import.py) in a specific location in the server, say /tmp/OSBScripts.

Few considerations for build.properties
     a. fmw.home=/u01/app/oracle/product/fmw
                           here, mention the path of FMW home

     b. wls.username= weblogic
         wls.password=abc123
                         here, specify the username and password used to connect to server

     c. wls.server  = t3://lpdwa1109.trcw.us.aexp.com:7002
                         here,
                               - t3 protocol is used
                               - port should be the admin server port

     d. export.project=DummyTest
                        here, mention the name of the project that needs to be exported.

     e. export.jar=/tmp/debadri/sbconfig_DummyTest.jar
                        here, specific the jar file name and the location where the project will be exported.

     f. export.customFile=/tmp/debadri/bamdatecheck.xml
                       here, mention the location and name of customization file, if any

     g. import.jar= /tmp/debadri/sbconfig_DummyTest.jar
                       here, mention the name and location of the JAR file which needs to be imported.

     h. import.customFile = None
                      here, name and location of customization file to be applied to the imported jar if any.

Few considerations for build.xml
      a.  <property name="domain.export.script" value=" /tmp/OSBScripts/export.py"/>
      b.  <property name="domain.import.script" value=" /tmp/OSBScripts/import.py" />
                        Always better to specify the full path of export.py and import.py.
      c. We are going to specify the script to execute in the "fileName" property of <wlst>

Here's the oracle doc link to get an insight into using other attributes of <wlst> in running WLST from Ant for WLS 10.3.5

4. Run ant targets from the location where build.xml is placed.

>/tmp/OSBScripts $ <FMW_HOME>/modules/org.apache.ant_1.7.1/bin/ant exportFromOSB
OR
>/tmp/OSBScripts $  <FMW_HOME>/modules/org.apache.ant_1.7.1/bin/ant importToOSB


Here, exportFromOSB - Ant target that exports OSB project from server
          importToOSB -   Ant target that deploys OSB project from local system to the server


[Note: The wlst task is predefined in the version of Ant shipped with WebLogic Server. If you want to use the task with your own Ant installation, add the following task definition in your build file: 
<taskdef name="wlst" classname="weblogic.ant.taskdefs.management.WLSTTask"/>]

All the files (build files and Jython scripts) referred in this link can be found here

______________
thanks, D


3 comments:

  1. Hi, I need to do the import of OSB Projects (jars and customization files) without ant tasks, I mean, only using WLST commands. What should I do to do this? Sorry about my horrible english I'm from Argentina.
    Regards

    ReplyDelete
    Replies
    1. Hi Mauri - Sorry for the late reply.
      Basically you need to run the import.py file.
      The following command invokes WLST, executes the specified script, and exits the WLST scripting shell. To prevent exiting WLST, use the -i flag.

      C:\>java weblogic.WLST import.py
      C:\>java weblogic.WLST -i import.py

      Pls note, in my build.xml the following two lines are put in seperately and not in the jython script

      connect(adminUser,adminPassword,adminUrl) domainRuntime()

      So, you can do 2 things -


      A1. Either invoke WLST first [java weblogic.WLST]
      A2. Connect to the Weblogic server instance [connect(adminUser,adminPassword,adminUrl)]
      A3. Set up domain Runtime [domainRuntime()]
      A4. Execute the script [execfile(filePath/filename.py)]

      OR

      B1. Include the above two line in the import.py script
      B2. Invoke WLST and run the jython script at one shot.

      Hope this helps.

      Delete
  2. Thank you for the scripts!
    Can we export multiple projects using this script?

    ReplyDelete