Monday, February 20, 2012

Configure WebLogic Resource Adapters with ANT

When you use a JCA adapter in Oracle SOA Suite or OSB then you know that you need to configure a plan of some WebLogic Resource Adapter.  With this ANT script I tried to make this an easy task for you and which you can repeat on different WebLogic Domains. This ANT script can easily add multiple EIS entries to the following adapters: DbAdapter, AqAdapter and JmsAdapter in just one run. After these changes to the resource plans this script will redeploy only the changed Resource Adapter.

Special thanks for my colleague Michel Schildmeijer for inspiring me to make this flexible script and off course for the necessary WLST code.

Important to know.

  • Run this script on the AdminServer, else it won't find the Resource Adapter Plans
  • First you need to create a Plan for the 3 Resource Adapters (Db,Aq,Jms) and add a dummy entry, think how you name it and where you put it.
  • When a plan is changed and you have a soa cluster or the soa weblogic instance is running on a different server then you need to copy the plan to all servers or put it on a shared storage.    

If you don't like this then you can always create new Resource Adapters by following this blogpost.

Let's explain how it works

first you need to change some variables in this build.properties

default this scripts runs against the weblogic dev settings.  You can change this to your own and configure the dev entries ( dev entries at the bottom of the build.properties )

wls.environment=dev

Where are the adapter rars located in your FMW domain, this can be in your SOA or OSB Home of the FMW domain.
connectorLocation=C:/oracle/MiddlewarePS3/Oracle_SOA1/soa/connectors/

Then add your own EIS entries, these ones in this var will be added to weblogic.
resourceAdapterEntries=hrDB,hrAQ,cf1JMS,cf2JMS

Think if you need to set the XA or Not XA datasource property or in Jms the connectionFactoryLocation.
# AQ entry
hrAQ.type=aq
hrAQ.eisName=eis/AQ/hr2
hrAQ.property=xADataSourceName
hrAQ.value=jdbc/hrDS

# DB entry
hrDB.type=db
hrDB.eisName=eis/DB/hr2
hrDB.property=dataSourceName
hrDB.value=jdbc/hrDS

# JMS entries
cf1JMS.type=jms
cf1JMS.eisName=eis/JMS/hr3
cf1JMS.property=ConnectionFactoryLocation
cf1JMS.value=jms/MyCF

After you can run the ANT script 
ant -f build.xml createResourceAdapterEntries 

Here you can download the code on github

Here is the whole build.properties file 


The wlst part with the wlRedeployResourceAdapter and wlCreateResourceAdapter macrodefs


And at last the build.xml

12 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Hi,

      I don't think you got this soaps3 connection on your side
      [wlst] Connecting to t3://soaps3:7001 with userid weblogic ...

      thanks

      Delete
    2. This comment has been removed by the author.

      Delete
    3. hi,

      I think you are some ant libs jars or the ant contrib jar. put them in your ant lib or classpath.

      thanks

      Delete
    4. Hi Biemond,

      Could not load definitions from resource org/apach
      e/tools/ant/antlib.xml. It could not be found.
      where can find this lib iam unable to locate it...

      Delete
    5. It is located at the lib folder on github and loaded in the bat file.

      thanks

      Delete
    6. Hi Edwin,
      Iam able to execute the build successfully but the changes are not reflected on weblogic server, dont know where the problem is here pasting the log....

      Delete
    7. Hi,

      you must upgrade ANT and check your classpath and put contrib jar in the ant lib folder.

      thanks

      Delete
    8. This comment has been removed by the author.

      Delete
  3. Hi, Edwin,
    Thanks for share your code in GitHub, save me lots of time.
    1. I did little change for my env. It's not problem in my Linux with using PlanPath, but don't know why it's not working in my Windows. just return Plan.xml without path.
    planPath = get('/AppDeployments/'+appName+'/AbsolutePlanPath')

    2. The destroy exist Variable/assignment function is not working in makeDeploymentPlanVariable, because you introduce idRandom on the name param. Either change this idRandom to FIXED string/number, or using find() to filter the exist Variable then destroy that. Otherwise always create new Avariable with the same eisName.

    thanks

    ReplyDelete
    Replies
    1. Thanks for your input.

      I tested it on windows without any problem.

      Thanks

      Delete