November 15, 2010

Redeploy application to Weblogic Server through Ant script

The most time consuming task in a Web app development is to redeploy the application into the server for every change and test it.

In Weblogic Workshop IDE, we have an option to redeploy the app into Weblogic server by just right clicking it. But in Intellij Idea, I was not able to find such feature. We spent considerable amount of time to redeploy application using 'Weblogic Console' until we figured out the 'Ant' script to do it.

<project>
<property name="bea.home" value="C:/bea"/>
<property name="wl.home" value="${bea.home}/weblogic92"/>
<property name="wl.domain" value="domainName"/>
<property name="wl.server" value="serverName"/>
<!-- classpath to have weblogic.jar as the first jar -->
<path id="base.path">
<fileset file="${wl.home}/server/lib/weblogic.jar"/>
<fileset dir="${wl.home}/server/lib/">
<include name="**/*.jar"/>
</fileset>
<pathelement path="${java.class.path}/"/>
</path>

<!-- weblogic tasks-->
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath refid="base.path"/>
</taskdef>
<taskdef name="wlserver" classname="weblogic.ant.taskdefs.management.WLServer">
<classpath refid="base.path"/>
</taskdef>

<target name="deployApp">
<wldeploy action="deploy" verbose="true" debug="true"
name="sampleApp" source="z:/app/target/sampleApp.ear"
user="weblogic" password="weblogic"
adminurl="t3://localhost:7001" targets="${wl.server}"/>
</target>

<target name="redeployApp">
<wldeploy action="undeploy" verbose="true" debug="true" name="sampleApp" 
user="weblogic" password="weblogic"
adminurl="t3://localhost:7001" targets="${wl.server}"/>
<wldeploy action="deploy" verbose="true" debug="true"
name="sampleApp" source="z:/app/target/sampleApp.ear"
user="weblogic" password="weblogic"
adminurl="t3://localhost:7001" targets="${wl.server}"/>
</target>
</project>

TIP:
Use SUBST command in Windows to map your project location to a new drive. For eg.,
subst z: d:/venky/projects/utils/sampleApp 

Individual developers in the team can checkout the code to any location but using this SUBST command will help the team to refer the project from same location like z:/src. Even though IDE's use relative path, it is nice to do this as the team can use these kinds of file without any customization.

1 comment:

  1. Great Article. Thank you for sharing! Really an awesome post for every one.

    IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

    Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
    Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

    ReplyDelete