WLST – BEAWorld session – part 3

Continuing with the demo, this will be the final part of the demo.
Now we have a running domain that has an Administration server, two managed servers that belong to a Cluster. For the final part of my demo I used a script that deployed a simple web application to the cluster using the ‘deploy’ command. WLS 9.0 implements the JSR88 API’s for all deployments and WLST surfaces all the deployment functionality using these API’s. The script is shown below.

from java.lang import Runtime
print “Deploying demo application”
deploy(“demo”, “d:/bea/apps”, “mycluster”)
print “Done deploying to cluster”
Runtime.getRuntime().exec(“rundll32 url.dll,FileProtocolHandler http://localhost:8001/beaworld”)

In the script I used the class java.lang.Runtime to start a browser that points to the web app that I just deployed. This demonstrates one of the most useful features of Jython that is able to seemlessly invoke on any Java object. You can also create/modify deployment plans via WLST. If you are not familiar with what a deployment plan is, it is an XML document that resides outside of an application archive and configures an application for deployment. A deployment plan works by setting deployment property values that would normally be defined in an application’s WebLogic Server deployment descriptors, or by overriding property values that are already defined in a WebLogic Server deployment descriptor. For more information on deployment plan’s check out BEA edocs. For the demo I re-deployed the webapp with a deployment plan that overrides the web app’s context root from ‘beaworld’ to ‘wlst’. Before redeploying the application here’s the script that you can use to create a plan and override the context root.

# This will load the application and return a plan object
myplan=loadApplication(“d:/bea/apps”)
# create a Variable
myplan.createVariable(“croot”,”wlst”)
# assign the variable to the module descriptor
cc=myplan.createVA(“croot”,”apps”,”WEB-INF/weblogic.xml”)
# set the xpath
cc.setXpath(“/weblogic-web-app/context-root”)
# save the plan
myplan.save()

and the redeploy script is shown below.

print “Re-Deploying demo application with a Plan”
redeploy(“demo”, planPath=”d:/bea/plan.xml”)
print “Done re-deploying to cluster with plan”
Runtime.getRuntime().exec(“rundll32 url.dll,FileProtocolHandler http://localhost:8001/beaworld”)

The plan.xml is shown below.

<deployment-plan xmlns=”http://www.bea.com/ns/weblogic/90″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>
···<application-name>apps</application-name>
······<variable-definition>
·········<variable>
············<name>croot</name>
············<value>wlst</value>
·········</variable>
······</variable-definition>
······<module-override>
·········<module-name>apps</module-name>
·········<module-type>war</module-type>
·········<module-descriptor external=”false”>
············<root-element>weblogic-web-app</root-element>
············<uri>WEB-INF/weblogic.xml</uri>
············<variable-assignment>
···············<name>croot</name>
···············<xpath>/weblogic-web-app/context-root</xpath>
············</variable-assignment>
·········</module-descriptor>
·········<module-descriptor external=”false”>
············<root-element>web-app</root-element>
············<uri>WEB-INF/web.xml</uri>
·········</module-descriptor>
······</module-override>
···<config-root xsi:nil=”true”></config-root>
</deployment-plan></font>

This is the end of the demo. You can also get more information on all the sessions that are presented at BEAWorld here.

_uacct = “UA-2684269-2″;
urchinTracker();

One Response to “WLST – BEAWorld session – part 3”

  1. Smriti says:

    I am trying to write an Offline WLST script which is the counterpart of an Online Script to create managed servers, which is similar to your script.

    However, on running the online script I am getting the WebServer and JTAMigratable Target elements automatically, but with the Offline script these elements are not getting created.

    Any ideas?