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


Building “wlfullclient.jar”

Hi,

Jay SenSharma

Jay SenSharma

WebLogic Server 10.0 and higher releases, client applications should use the wlfullclient.jar file to provide the WebLogic Server specific functionary previously provided in the weblogic.jar file. You can generate the wlfullclient.jar file for client applications using the JarBuilder tool. Here is a Simple ANT script to Build the “wlfullclient.jar” JAR Using ANT Script.

NOTE: Plesae be aware of the limitation/BUG associated with the  “wlfullclient.jar” wlfullclient.jar BUG … It never works with WLST

Step1). Place the following “build.xml” file in WebLogic Installations Server/lib directory….
Example: “C:bea103wlserver_10.3serverlib” place build.xml here

Note this is mendatory that u place the build.xml file inside the  above mentioned location or else u will have to edit the following XML file a lot…

<project name="JarBuilder" default="run">
<property name="bea.home" value="C:/bea103"/>
<property name="wl.home" value="${bea.home}/wlserver_10.3"/>

<path id="main.class.path">
<pathelement path="${bea.home}/modules/com.bea.core.utils_1.4.0.0.jar"/>
<pathelement path="${bea.home}/modules/com.bea.core.jarbuilder_1.2.0.0.jar"/>
<pathelement path="${java.class.path}"/>
</path>

<target name="run">
<echo message="***ANT Script should run from inside the ${wl.home}/server/lib *****" />
<echo message="***** ********* ********* *****" />
<java classname="com.bea.jarbuilder.JarBuilder">
<classpath refid="main.class.path"/>
<jvmarg value="-d ${wl.home}/server/lib -jar wljarbuilder.jar"/>
</java>
</target>
</project>

Step2). Modify th Properties defined in the ANT script according to your Installation directory:
<property name=”bea.home” value=”C:/bea103″/>
<property name=”wl.home” value=”${bea.home}/wlserver_10.3″/>

Step3). Open a command prompt and the Run the ANT script…means open a command prompt run the setWLSENV.cmd then run Ant…
Once the ant script executed successfully…you will find “wlfullclient.jar” is generated in “C:bea103wlserver_10.3serverlib” location

.

.
Thanks
Jay SenSharma


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