Pages

Monday, May 3, 2010

Weblogic Deployment Plan

Share it Please

A deployment plan Is a plain xml document that defines a application deployment configurations that are specific for a weblogic server environment such as Production, Test and Development. The deployment plan exists outside of the application archive and will override the configurations specified by the application descriptors. We can use the deployment plan to easily change the configurations from production to test and development.

The deployment plan lets an admin define specific features for a deployment in an xml file and re-use them for different deployments. For example, a web application in a production environment has a context root as /example and in test or development we need to specify the context root as /examples for the same web application, then we can create a deployment plan from the production environment. We can edit it, change the context root and deploy the same in the test and development environments [but we have a different context roots]

We will use the SimpleSample application in our Demo. this is a simple application with a servlet which prints a message on the screen.

First we will deploy the application into the weblogic server , just follow the steps below for deploying the application ..

Click On Deployments [on the Left Hand Tree]
On the right hand side, you will see a “Summary of deployments” -> select “install”
Now select the path where your war file is available -> Next
Select “install the deployment as an application” -> Next
Select the target -> Next
Next -> Next - > Finish

You can the test the application by going to
Deployments -> Application Name ->Testing

Once the application is deployed and working , we will see how to create a deployment plan for the simpleSample application.

Go to Deployments -> select the application “SimpleSample”
Go to Configuration Tab -> make some changes [I changed the Session Timeout (in seconds): to 3601 from 3600 ]
Save [ you will asked for saving the deployment plan as plain.xml ] .save it

Now lets edit the deployment plan . open the deployment plan.xml file in a text editor.

An excerpt from the deployment plan.xml file generated on my desktop

<?xml version='1.0' encoding='UTF-8'?>
<deployment-plan xmlns="http://www.bea.com/ns/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/deployment-plan http://www.bea.com/ns/weblogic/deployment-plan/1.0/deployment-plan.xsd" global-variables="false">
<application-name>deploy_plan</application-name>
<variable-definition>
<variable>
<name>SessionDescriptor_invalidationIntervalSecs_12706221845760</name>
<value>50</value>
</variable>
</variable-definition>
<module-override>
<module-name>SimpleSample.war</module-name>
<module-type>war</module-type>
<module-descriptor external="true">
<root-element>weblogic-web-app</root-element>
<uri>WEB-INF/weblogic.xml</uri>
<variable-assignment>
<name>SessionDescriptor_invalidationIntervalSecs_12706221845760</name>
<xpath>/weblogic-web-app/session-descriptor/invalidation-interval-secs</xpath>
</variable-assignment>
<hash-code>1270622184576</hash-code>
</module-descriptor>
<module-descriptor external="false">
<root-element>web-app</root-element>
<uri>WEB-INF/web.xml</uri>
</module-descriptor>
<module-descriptor external="true">
<root-element>wldf-resource</root-element>
<uri>META-INF/weblogic-diagnostics.xml</uri>
</module-descriptor>
</module-override>
<config-root>C:\Documents and Settings\xprk477\Desktop\deploy_plan\plan</config-root>
</deployment-plan>

The mechanism works as follows first we need to define a variable in brown section and then assigning it to the application [purple section] . the xpath element in the variable-assignment is just a link to the element in the weblogic.xml descriptor. We have changed the session invalidation interval seconds, so now this value will reflect the value in weblogic.xml‘s session invalidation interval second .

Coming to our Demo , we will add a “WeblogicWebApp_ContextRoots” element to the deployment plan.xml file since we need to change the context root element from “SimpleSample” to some other .now my modified deployment plan.xml looks like this ,

<?xml version='1.0' encoding='UTF-8'?>
<deployment-plan xmlns="http://www.bea.com/ns/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/deployment-plan http://www.bea.com/ns/weblogic/deployment-plan/1.0/deployment-plan.xsd" global-variables="false">
<application-name>deploy_plan</application-name>
<variable-definition>
<variable>
<name>WeblogicWebApp_ContextRoots_12706221845760</name>
<value>"/songissong"</value>
</variable>
<variable>
<name>SessionDescriptor_invalidationIntervalSecs_12706221845760</name>
<value>50</value>
</variable>
</variable-definition>
<module-override>
<module-name>SimpleSample.war</module-name>
<module-type>war</module-type>
<module-descriptor external="true">
<root-element>weblogic-web-app</root-element>
<uri>WEB-INF/weblogic.xml</uri>
<variable-assignment>
<name>WeblogicWebApp_ContextRoots_12706221845760</name>
<xpath>/weblogic-web- app/context-root</xpath>
<operation>replace</operation>
</variable-assignment>
<variable-assignment>
<name>SessionDescriptor_invalidationIntervalSecs_12706221845760</name>
<xpath>/weblogic-web-app/session-descriptor/invalidation-interval-secs</xpath>
</variable-assignment>
<hash-code>1270622184576</hash-code>
</module-descriptor>
<module-descriptor external="false">
<root-element>web-app</root-element>
<uri>WEB-INF/web.xml</uri>
</module-descriptor>
<module-descriptor external="true">
<root-element>wldf-resource</root-element>
<uri>META-INF/weblogic-diagnostics.xml</uri>
</module-descriptor>
</module-override>
<config-root>C:\Documents and Settings\xprk477\Desktop\deploy_plan\plan</config-root>
</deployment-plan>

I just modified the web-context from “simpleSample” to “songissong” . In order to override the context root we need to do a replace operation in the variable assignment since the element already exists in the archive.

Now we need to update the current application with the changes we made to the plan ,

Go to Deployments -> select the Application “SimpleSample” -> click Update
In the next window we will see “Deployment plan path:” , select “Change Path” and select the updated the deployment plan.xml file and click Next. Select Finish

Now test your application and we will see that the context element is changed.


Happy learning , More to Come