Wednesday, October 28, 2009

Dynamic Domain creation with WLST

Introducing Dynamism

Hey all wise WLA welcome to this exclusive WLST blog again!

My dear buddies, this week I was invited  for a discussion on generic and dynamic domain creation in WebLogic for a development environment. The need of a script that is generic in the sense not specific to any operating environments such as Solaris, Linux, Windows or Mac. And, It should prompt for all the desired inputs to build a basic WebLogic domain in a development environment.

It looks like some what interactive and can be dynamic.

After looking into many search engines we did not get any generic or dynamic one. We took this from some part of the script from WebLogic forums and some from python forums. Finally got into conclusion that you need few lines of python required for Operating environment details to fetch from the system.

Why Dynamic Domain Script?
  • The richness of this script is that,  you can use this for your environment directly.
  • This is reusable script.
  • It is for time saving compare to the regular config.sh execution
  • ease of use script
  • You can execute on Windows same script can run on Solaris without any changes
We also experimented this same script executed in WebLogic 9.x version and again in WebLogic 11g also successfully. So this dynamic and generic domain configuration script publishing for the all who want to explore the WLST with their experiments.

Prerequisites

To execute this script you must define the following:

1. JAVA_HOME define this from WebLogic installation paths
2. WL_HOME define this as WebLogic installation
3. CLASSPATH must have weblogic.jar for running weblogic.WLST
4. PATH must contain JAVA_HOME/bin to run java commands
After setting these you can verify above with echo each environment variable. In Nix platform you can try as:
echo $PATH
echo $CLASSPATH
echo $WL_HOME
echo $JAVA_HOME
In Windows you can verify it by replace $ with % symbol.



Sample Execution
Assume that you saved the above script with the name as "createDomain.py". Of course you can choose your own name for the script!
At your command prompt you can invoke this script as follows:

[WLA@server~/.AdminScripts]$ java weblogic.WLST createDomain.py 
 
Initializing WebLogic Scripting Tool (WLST) ...
 
Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands
 
Please Enter Admin ServerName: testAdmin
Please Enter Admin Listen Address: 127.0.0.1
Please enter Admin listen Port: 8007
Please Enter AdminUser Name: system
Please enter Admin password:weblogic103
Enter the domain path: /home/wluser/domains/    
Enter domain name: testdomain
Given domain path, name :  /home/wluser/domains/testdomain
 
Exiting WebLogic Scripting Tool.
 
[WLA@server~/.AdminScripts]$ cd ../domains
[WLA@server~/domains]$ ls 
nmdomain103    testdomain
Further improvements
1. You can improve this script for Clustered environment.
2. You can add more functions for each resource configurations such as JDBC DataSource, JMS, and application deployment
3. Verifying the given domain path is also recommended
4. The python script must have exception handling I mean there should try: except: blocks to make more robust.

Buddy you can extend your domain template using pack and unpack commands.

3 comments:

Priya Munukutla said...

hi,
I have WLST question. We are upgrading from 10.3.0.0. to 10.3.5.0. Is there a need to update WLST scripts? I mean is there any changes in WLST since 10.3.0.0?

Thanks,

Pavan Bhavani Shekhar said...

Priya, most of the scripts works, only you need to change connect() parameters. Cluster using scripts need to double check all the servers must be in RUNNING state.
what all the scripts using?

Anonymous said...

I am a newbie to weblogic. I took a sample Weblogic Script and i am unable to run that script. Can you please explain me in detail with an example.

Thanks...

Search This Blog

Loading...

My Favorites