Friday, March 12, 2010

HOT deployment setup from Eclipse to Weblogic server

When we are working on an enterprise application which consists of various modules and in big size, most of our development time is spent in building the application and redeploy on the Weblogic server to validate our changes. While we are updating one or two files at a time, still we are repeating the above steps all the time. This repeating deployment is resulting into slow validation and hence less productivity.

Below is the list of steps, if followed enables the hot deployment of our source code (useful in most of our working scenarios) without affecting any existing processes in place.

Weblogic Side Configuration:
1. Undeploy current enterprise application from Weblogic server.
2. Stop the Weblogic server
3. Create a folder named "MyEar" <Enterprise App Name> in applications folder in your Weblogic domains folder e.g. "C:\bea\user_projects\domains\mydomain\applications\"
4. Open the application ear with some zip utility and extract all the files into "MyEar" folder created in step2.
5. Create a blank file with the name as "REDEPLOY" in MyEar/APP-INF/META-INF folder.
6. Create a folder name "classes" in MyEar/APP-INF folder.
7. Extract the application web module(s) into a folder named "<Web Module Name>.war" in MyEar folder and remove the war file(s) from the folder.
8. Start the Weblogic Server, open admin console, and deploy MyEar<Enterprise application> Application by selecting MyEar<Enterprise application> folder.
9. If the deployment fails detailing any particular module, please open the respective module and correct the MANIFEST.MF file entries.

Eclipse Configuration:
1. Open Eclipse IDE
2. In each java module folder in workspace, create a file named as moduleBuild.xml <we can provide any name of our choice> with details below:

<project name="MyModule" default="hotDeploy" basedir=".">
<property file="build.properties"/>
<target name="hotDeploy">
<delete dir="${dl.dm.dir}\applications\${dep.ear.folder}\APP-INF\classes"/>
<mkdirdir="${wl.dm.dir}\applications\${dep.ear.folder}\APP-INF\classes"/>
<copy todir="${wl.dm.dir}\applications\${dep.ear.folder}\APP-INF\classes">
<fileset dir="${service.project.dir}/${build.dir}/classes"/>
</copy>
<touch file="${wl.dm.dir}\applications\${dep.ear.folder}\META-INF\REDEPLOY"/>
</target>
</project>


3. Create a file named build.properties with entries below(update the values as the local settings):
service.project.dir=../MyService
build.dir=build
dep.ear.folder=MyEar
wl.dm.dir=C:\bea\user_projects\domains\mydomain\applications


4. In each web module folder in workspace, create a file named as moduleBuild.xml <we can provide any name of our choice> with details below:

<project name="MyModule" default="hotDeploy" basedir=".">
<property file="build.properties"/>
<target name="hotDeploy">
<delete dir="${dl.dm.dir}\applications\${dep.ear.folder}\APP-INF\classes"/>
<mkdirdir="${wl.dm.dir}\applications\${dep.ear.folder}\APP-INF\classes"/>
<copy todir="${wl.dm.dir}\applications\${dep.ear.folder}\APP-INF\classes">
<fileset dir="${web.project.dir}/${build.dir}/classes"/>
</copy>
<copy todir="${wl.dm.dir }/applications/${dep.ear.folder}/${dep.war.folder}/jsp/${jsp.dir}">
<fileset dir="${web.project.dir}/WebContent/jsp/${jsp.dir}"/>
</copy>
<copy todir="${wl.dm.dir }/applications/${dep.ear.folder}/${dep.war.folder}/js/${js.dir}">
<fileset dir="${workspace.web.project.dir}/WebContent/scripts/${js.dir}"/>
</copy>
<touch file="${wl.dm.dir}\applications\${dep.ear.folder}\META-INF\REDEPLOY"/>
</target>
</project>


5. Create a file named build.properties with entries below(update the values as the local settings):
web.project.dir=../MyWeb

web.project.dir=../MyWeb
build.dir=build
dep.ear.folder=MyEar
dep.war.folder=MyWar.war
jsp.dir=myJsp
js.dir=myJs
wl.dm.dir=C:\bea\user_projects\domains\mydomain\applications


6. Right click each modules (including both Java and Web Modules)
7. Select properties from the menu
8. Select builds from the properties screen, and click on the "New" button in right side
9. In new screen, select Ant builder and hit "OK"
10. It opens "Edit Launch Configuration" screen.
11. Put any suitable name is the name field
12. In the main tab, browse the respective build xml file (moduleBuild.xml) from the project folder in workspace
13. go to targets tab, set the default target available in first three sections namely "After a Clean", "Manual Build" and "Auto Build"
14. Click Apply and OK to close the window
15. Click OK to close the other underlying window.
16. Once Steps 6-15 are completed for each module; restart your eclipse.


Now you are all set. If you are working on any jsp/js/java file (except EJBBean interface) through your eclipse IDE, your files are hot deployed on the Weblogic server in few seconds. Don’t forget to update Base Module JAR files in deployed MyEar<Enter

Hope this will be helpful in your development activities.

No comments:

Post a Comment