Tuesday, July 28, 2009

Weblogic-Creating domains using WLST scripts

WLST or weblogic scripting tool enables you to create a new domain or update an existing domain even if the weblogic server is not up and running there fore it is also called as offline work as you are not connected to a running instance.

We create a template using wlst scripts and then create a domain from that template.
The template is baiscally a jar file which contains all the configuratino details for a domain.

To start WLST script either use the following command

java weblogic.WLST after setting the class path and other variables,Better described in following threads

http://forums.oracle.com/forums/thread.jspa?threadID=880514&tstart=0&messageID=3637391

http://forums.oracle.com/forums/thread.jspa?messageID=3018767

or use the easy way.

go to following directory

C:\bea\wlserver_10.3\common\bin

and double click on WLST.cmd

It will open up a window like this



so if you will try to read the domain using the following command you might face issues like

Error: readDomain() failed. Do dumpStack() to see details.

Do the dumpStack() and get the details of the error.

In my case it says



Well i got the reason.We have to use the backward slash instead of forward slash while reading the domain.

so now i changed the forward slash to backward slash and it worked.



Now we will try to read the template

so before reading the template we need to disconnect from the existing domain.So we will be using the following command.

CloseDomain()

and then use the command readTemplate and point to our existing template.



We have some default wlst scripts provided in the following directory

C:\bea\wlserver_10.3\common\templates\scripts\wlst

Please find the extension as .py which means it is a python script.

YOu can just review basicWLSDomain.py to get an idea how do we create a simple domain.

Well you need to have good knowledge in python and knowledge of different component of server to write the script.

I will be simply using
checking writeTemplate and use createDomain command to give an idea how to create a domain.

YOu need to close your domain once you read it by closeDomain() and your template by using closeTemplate() command.



so now we will finally use createDomain Command to create a domain

Its template is like

createDomain(domainTemplate, domainDir, user, password)

so i will run the following command to create a new domain.

createDomain('C:/bea/user_templates/Cluster.jar','C:/bea/user_projects/domains/Cluster','weblogic','weblogic')

Please keep in mind that you have a directory called Cluster located in the following location

C:/bea/user_projects/domains

and is empty

So as soon as you will run this command it will create a domain.



So initially your domain directory was empty now you can find the configuration files corresponding to the domain including the startup script security details and server details etc.

may be we wil have a look in the same sometimes later.

1 comment:

Unknown said...

Thanks for providing good information,Thanks for your sharing.Python Online Course