Tag: ANT

Using WLST ANT Task to Get ServerDetails

Hi,

Jay SenSharma

Jay SenSharma

Here is a Simple Ant Script which internally uses the WLST AntTask …using this ANT Developers can easily utilize the WLST scripting features in their own ANT scripts.  (Just Make sure that the Indentation is correct while Typing your WLST snippet inside the <script> Tag…

The following Ant Script will demonstrate that how we can get the Name and the ListenAddress Port Details of all the Servers available in our Domain…

WLST Script To Get Server Details

WLST Script To Get Server Details

To run above “build.xml” file you need to run the “. ./setWLSEnv.sh” in the Shell prompt first sothat the CLASSPATH & PATH will be set…

ant

——————————–

OUTPUT:
C:JavaTestWLST_ANT>ant
Buildfile: build.xml

getServerDetails:
[wlst] <WLSTTask> All lines will be trimmed by 7
[wlst] <WLSTTask> The script that will be executed
[wlst] print ‘Connecting to WebLogic AdminServer…’
[wlst] connect(‘weblogic’,’weblogic’,’t3://localhost:7001′)
[wlst] svrs = cmo.getServers()
[wlst] print ‘Servers in the domain are’
[wlst] for x in svrs:
[wlst]       print x.getName()
[wlst]       print x.getListenPort()
[wlst]       print x.getListenAddress()
[wlst]       print ‘———————‘

[wlst] In the target loop
[wlst] Connecting to t3://localhost:7001 with userid weblogic …
[wlst] Successfully connected to Admin Server ‘AdminServer’ that belongs to domain ‘base_domain’.
[wlst]
[wlst] Warning: An insecure protocol was used to connect to the
[wlst] server. To ensure on-the-wire security, the SSL port or
[wlst] Admin port should be used instead.

[wlst] Servers in the domain are
[wlst] AdminServer
[wlst] 7001

[wlst] ———————
[wlst] MS1
[wlst] 7003

[wlst] ———————
[wlst] MS-2
[wlst] 7005

[wlst] ———————

BUILD SUCCESSFUL
Total time: 2 seconds


WebLogic Specific APPC ant task

Hi,

Jay SenSharma

Jay SenSharma

APPC is a WebLogic Specific Application Compiler tool. This tool is very useful in order to compile our applications according to the current version of WebLogic. Usually we use this tool to compiles EJBs and JSPs.

Here is a Simple example of APPC anttask…which compiles An EAR application which contains Multiple WAR files….the Output of the compilation will be placed in the location specified in “output” attribute of this Task, which can be deployed on WebLogic Server to avoid Deploy time Compilation Overhead.

Step1). Suppose we have a Simple EAR Application “TestDiagnosticsEAR” (you can even use WAR/JAR/EAR archieved or Un-Archived versions to compile) in the following location in our file System…”C:DELETEBLOG_REPLYAPPC”

Step2). Now write “build.xml” file in “C:DELETEBLOG_REPLYAPPC” Location…

<project name="WeblogicCompilation" basedir="." default="appc">
<property name="wl.home" value="C:/bea103/wlserver_10.3" />
<property name="application.dir" value="C:/DELETE/TestDiagnosticsEAR" />

<path id="wlappc.classpath">
        <fileset dir="${wl.home}/server/lib">
              <include name="*.jar"/>
        </fileset>
</path>

<taskdef name="wlappc" classpathref="wlappc.classpath" classname="weblogic.ant.taskdefs.j2ee.Appc"/>

<target name="appc">
<wlappc source="${application.dir}"
        keepgenerated="true"
        verbose="true"
        output="${application.dir}_Output"/>
</target>
</project>

Step3). Now run the Above ANT Script:

after setting the JAVA_HOME and ANT_HOME Better And Recommended if you will run “. ./setWLSEnv.sh” from WebLogic server/bin directory.

Note: “. ./setWLSEnv.sh”       The first DOT represents that set the Environment in the current Shell, AND the second ./ represents execute the script from the current directory. Both DOTs are separated by a single white space character.

Step4). Analyze the “output=”${application.dir}_Output” directory …you will find that all your JSPs and EJBs(if any) are compiled.

—————————

Output:

C:DELETEBLOG_REPLYAPPC>ant
Buildfile: build.xml

appc:
[wlappc] <Feb 8, 2010 4:52:03 PM IST> <Info> <J2EE> <BEA-160186> <Compiling EAR module ‘SecondWebApp_A’>
[wlappc] [JspcInvoker]Checking web app for compliance.
[wlappc] [jspc] Overriding default descriptor option ‘keepgenerated’ with value specified on command-line ‘true’
[wlappc] [jspc] -webapp specified, searching . for JSPs
[wlappc] [jspc] Compiling /index.jsp
[wlappc] <Feb 8, 2010 4:52:06 PM IST> <Info> <J2EE> <BEA-160186> <Compiling EAR module ‘SecondWebApp_B’>
[wlappc] [JspcInvoker]Checking web app for compliance.
[wlappc] [jspc] Overriding default descriptor option ‘keepgenerated’ with value specified on command-line ‘true’
[wlappc] [jspc] -webapp specified, searching . for JSPs
[wlappc] [jspc] Compiling /index.jsp
[wlappc] Compilation completed successfully.

BUILD SUCCESSFUL
Total time: 5 seconds
————————–

Thanks

Jay SenSharma


Ant to Deploy Applications

Hi,

Jay SenSharma

Jay SenSharma

Form WLS 9.x onwards in Admin Console we have a Feature called as “Lock & Edit”. It has many advantages but Some Adminstrators always complaint that because of this feature they need to keep on click on this button before deploying Any Application on WLS Server ..then there are several pages in the process of Deployment through Admin Console…for testing when we want to keep on deploying Applications /redeploy and undeploy them. Like in Dev Environments..This Simple ANT script will save our lots of time.

I have a very simple ANT Script which i use most of the time for quick deployment/redeployment/undeployment.

Just have a look … it is  good.

Step1). WhereEver you have placed your Jar/WAR/EAR file to be deployed on the Server Just Paste this “build.xml” file. Just change the Property values according to your requirement in the below file…
“build.xml”

<project name="webservices-hello_world" default="deploy">
<property name="wls.username" value="weblogic" />
<property name="wls.password" value="weblogic" />
<property name="wls.hostname" value="localhost" />
<property name="wls.port" value="7001" />
<property name="admin.server.name" value="AdminServer" />
<property name="deploy.target" value="ClusterNameABC" />
<!-- Here you can specify Either ClusterName, IndividualServerName Like "ManagedOne" or comma Seperated List of Managed/AdminServer -->
<property name="deploy.name" value="TestApp" />
<property name="deploy.source" value="TestApp.ear" />

<!-- Setting TaskDefinition -->
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath>
<pathelement location="C:/bea103/wlserver_10.3/server/lib/weblogic.jar"/>
</classpath>
</taskdef>

<!-- Deploying Applications  -->
<target name="deploy">
<wldeploy action="deploy"
          name="${deploy.name}"
          source="${deploy.source}"
          user="${wls.username}"
          nostage="true"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>

<!-- Redeploying Applications  -->
<target name="redeploy">
<wldeploy action="redeploy"
          name="${deploy.name}"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>

<!-- Uneploying Applications  -->
<target name="undeploy">
<wldeploy action="undeploy"
          name="${deploy.name}"
          failonerror="false"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>
</project>

Step2). Whenever you want to deploy the Application Just Change the Properties according to your requirement.

Step3). Open a command Window and then run (setWLSenv.cmd or setWLSEnv.sh or setDomainEnv.sh or setDomainEnv.cmd)

Step4). To Deploy the Application move to the current directory where ever you have placed “build.xml” and “TestApp.ear” (Your Application) and then run

ant deploy

Step5). To Redeploy the Application

ant redeploy

Step6). To Undeploy the Application

ant undeploy

.

.

Thanks
Jay SenSharma


Copyright © 2010-2012 Middleware Magic. All rights reserved. |