Pages

Tuesday, July 3, 2012

Do WebLogic configuration from ANT

With WebLogic WLST you can script the creation of all your Application DataSources or SOA Integration artifacts( like JMS etc). This is necessary if your domain contains many WebLogic artifacts or you have more then one WebLogic environment. If so, you want to script this so you can configure a  new WebLogic domain in minutes and you can repeat this task with always the same result.

I started a new project on Github https://github.com/biemond/soa_tools/tree/master/ant_wls which can do this from ANT, for this I created some WLST ANT macrodefs. These ANT targets can be invoked many times ( great for Continuous Integration ) and if the object already exists it rollbacks the edit action and give a BeanAlreadyExists exception. Great way to keep all your environments in sync.

These ANT scripts can do the following configuration.

  • Create users and roles
  • Reset or create JDBC DataSources 
  • File or JDBC persistence stores
  • JMS servers
  • JMS modules
  •    Sub Deployments
  •    Foreign Servers
  •       Foreign Server Destinations
  •       Foreign Server Connection Factories
  •    Connection Factories
  •    Queues ( Distributed )
  •    Topics ( Distributed )
  •    SAF Remote Contexts
  •    SAF Imported Destinations 
  • SAF agents 

Still to do  is the creation of SAF Imported Destinations.   

An example of an ANT macrodef with the WLST code for the creation of a Queue or a Topic on a WebLogic server or cluster, also supports distributed Queue or Topics plus re-directing to an other Queue.



Snippet of the ANT build.xml with the ANT target which calls this Macrodef and uses the build.properties for all the JMS objects definitions. The foreach is provided by the ANT Contrib library, this is not part of ANT and need to downloaded separately .


Snippet of the build.properties with all the weblogic environments. Just change wls.environment to acc or   some other value.

wls.environment=dev

# dev deployment server weblogic
dev.serverURL=t3://localhost:7001
dev.user=weblogic
dev.password=weblogic1
dev.target=AdminServer

# acceptance deployment server weblogic
acc.serverURL=t3://soaps3:7001
acc.user=weblogic
acc.password=weblogic1
acc.target=soa_server1



# All jms objects entries like Queue, Topic or distributed
queuesOrTopics=error1,queue1

# JMS module name
error1.jmsModule=JMSModule1
# JMS module subdeployment.
error1.subDeployment=JmsServer
error1.jmsName=ErrorQueue      
error1.jmsJNDIName=jms/ErrorQueue
# queue, topic
error1.jmsType=queue
# distributed true ,false
error1.distributed=false
error1.balancingPolicy=xxxxx
# redirect to an error Queue
error1.redirect=false
error1.limit=xxxxx
error1.policy=xxxxx      
error1.errorObject=xxxxx

queue1.jmsModule=JMSModule1
queue1.subDeployment=JmsServer
queue1.jmsName=Queue1      
queue1.jmsJNDIName=jms/Queue1
queue1.jmsType=queue
queue1.distributed=false
queue1.balancingPolicy=xxxxx
queue1.redirect=true
queue1.limit=3
queue1.policy=Redirect
queue1.errorObject=ErrorQueue

And we can run the ANT target when we execute the following command.

ant -f build.xml createCreateJMSQueuesOrTopics


https://github.com/biemond/soa_tools/tree/master/ant_wls

7 comments:

  1. And now you post this, just after I spent weeks on writing this kind of stuff for automated deployments of SOA, OSB, UCM and OIM (in EDG type variations). You could have saved me loads of time :)

    ReplyDelete
  2. Edwin thanks for the nice post. Does this work for Weblogic 9 as well?

    ReplyDelete
  3. Very cool. I did pretty much the same for a customer in 2011. Very alike.
    Tim Vissers

    ReplyDelete
  4. HI Edwin.
    Thanks for the post. I have used jenkins/hudson tool for deployment in 2011 where i had manually written ant scripts and called the ant targets in jenkins. Now when we say about continuous integration do we have readily available scripts or plug in to deploy soa projects to weblogic server. ????? Or we need to manual write the scripts??

    ReplyDelete
  5. Hi Edwin,
    Thanks for the post. I used the jenkins tool in 2001 where i have configured the ant scripts to deploy sar file and osbconfig.jar files to weblogic server by calling the relevant ant targets. When we say about continous integration project will we get readily available scripts to deploy code to weblogic server or a plug in to deploy the code of oracle FMW??? Please clarify?

    ReplyDelete
  6. Hi Edwin,
    Thanks for the post. I used the jenkins tool in 2001 where i have configured the ant scripts to deploy sar file and osbconfig.jar files to weblogic server by calling the relevant ant targets. When we say about continous integration project will we get readily available scripts to deploy code to weblogic server or a plug in to deploy the code of oracle FMW??? Please clarify?

    ReplyDelete