How to put sever in debug mode by using ANT script - ant

I am able to start Weblogic server by using ANT i need to start this server now in debug mode,
plz help
used following script for starting server.
<target name="startserver" depends="stopserver">
<wlserver dir="${domain.home}/${domain.name}" host="${host}" port="${port}" domainname="${domain.name}"
servername="${admin.server.name}" action="start" username="${username}" password="${password}"
beahome="${bea.home}" weblogichome="${weblogic.home}" verbose="true" noexit="true" protocol="t3"
classpath="${weblogic.home}/server/lib/weblogic.jar">
<jvmarg value="-server"/>
<jvmarg value="-Xms256m"/>
<jvmarg value="-Xmx512m"/>
<jvmarg value="-XX:PermSize=128m"/>
<jvmarg value="-XX:MaxPermSize=256m"/>
</wlserver>
</target>
Thanks in advance

You can add the following jvmarg in the ant task.
-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8473,server=y,suspend=n -Djava.compiler=NONE

Related

Ant script exec

I'm trying to automate build for my IBM Integration Bus applications. I'm using Jenkins and Ant to do this.
<?xml version="1.0"?>
<project name="project" default="run">
<target name="run" description="">
<property name="toolkit.home" value="C:\Program Files\IBM\IIB\10.0.0.10\server\bin" />
<property name="cmd.home" value="C:\Windows\System32" />
<property name="cmd.file" value="${cmd.home}\cmd.exe"/>
<property name="iib.cmd" value="C:\Program Files\IBM\IIB\10.0.0.10\iib.cmd"/>
<antcall target="build" />
</target>
<target name="build">
<exec executable="${cmd.file}">
<arg value="/k"/>
<arg value="${iib.cmd}"/>
</exec>
<exec executable="mqsilist" newenvironment="false"/>
</target>
</project>
The first exec will set up the IIB build environment. The next exec will list all the Integration nodes installed on the machine. When the script is run, the second exec throws an error. "System can't find the specified file".
When I run the above commands in Powershell or cmd they work fine.
F:\Ant>C:\Windows\System32\cmd.exe /k "C:\Program Files\IBM\IIB\10.0.0.10\iib.cmd"
F:\Ant>mqsilist
What I exactly mean to say is the build environment which the first exec sets is lost. I don't want ant to loose the build environment set by first exec. Tried using newenvironment="false". It didn't work.
Any help would be appreciated.

Apache tomcat server 7.0.42 fails to start after running ant build script

I am using apache ant 1.9.4. I have written build xml for starting apache tomcat server 7.0.42. But the server closes as soon it gets started. Also the build is showing successfull.
My build.xml is.,
<property name="build.dir" value="aar" />
<property name="deploy-location" value="D:\EIT SOFTWARES\apache-tomcat-7.0.42_aqar\webapps" />
<property name="catalina.home" value="D:\EIT SOFTWARES\apache-tomcat-7.0.42_aqar"/>
<property name="tomcat" value="${catalina.home}" />
<target name="start-tomcat">
<echo message="Starting tomcat">
</echo>
<exec executable="${catalina.home}\bin\startup.bat"></exec>
</echo>
</target>
What i am making wrong. Ant experts please help me.

Deploy .ear with Ant to WebLogic Server fails

I have build a working Java application which I can succesfully build and deploy to my WebLogic11g server.
I'm automating this process now with Ant.
I can build my application, the builded application works fine when deployed manually. But the deployment trough Ant isn't working.
My Ant file:
<!-- GENERAL -->
<property name="project.dir" value="CustomReportingProvider"/>
<!-- JAR -->
<property name="deploy.dir" value="${project.dir}/deploy"/>
<property name="jar.deploy.dir" value="${deploy.dir}/jar"/>
<property name="jar.classes.dir" value="${project.dir}/classes"/>
<property name="jar.meta-inf.dir" value="${jar.classes.dir}/META-INF"/>
<!-- EAR -->
<property name="ear.meta-inf.dir" value="src/META-INF"/>
<target name="clean">
<delete dir="${deploy.dir}"/>
</target>
<target name="package" depends="clean">
<mkdir dir="${deploy.dir}"/>
<mkdir dir="${jar.deploy.dir}"/>
<jar destfile="${deploy.dir}/jar/VSBReportingProvider.jar" basedir="${jar.classes.dir}" includes="**/*/*.class">
<metainf dir="${jar.meta-inf.dir}" includes="*.xml"/>
</jar>
<ear destfile="${deploy.dir}/VSBReportingProvider.ear" basedir="${jar.deploy.dir}" appxml="${ear.meta-inf.dir}/application.xml">
<metainf dir="${ear.meta-inf.dir}" includes="*.xml" excludes="application.xml"/>
</ear>
</target>
<path id="wlappc.classpath">
<fileset dir="C:\Oracle\Middleware10.3.4\wlserver_10.3\server\lib">
<include name="*.jar"/>
</fileset>
</path>
<taskdef name="wldeploy" classpathref="wlappc.classpath" classname="weblogic.ant.taskdefs.management.WLDeploy"/>
<target name="deploy" depends="package">
<wldeploy action="deploy"
name="VSB Reporting Provider"
source="${deploy.dir}/VSBReportingProvider.ear"
user="weblogic"
nostage="true"
password="weblogic1"
verbose="true"
adminurl="t3://localhost:7001"
targets="AdminServer"
debug="true"/>
</target>
The response: http://pastebin.com/x0En9WtA
It keeps saying it can not connect to the server, so I checked the following:
weblogic / weblogic1 account works.
AdminServer is running, can log-on to it.
The 'Enable tunneling' option is enabled.
The same application can be installed trough the web console.
Any help or idea on where to look, would be appreciated.
I find an answer on the Middleware Magic site:
Then please make sure to add "wlfullclient.jar" at the beginning of the CLASSPATH in your >ANT Script...Also please refer to http://forums.oracle.com/forums/thread.jspa?threadID=2188580&tstart=0 - See more at: http://middlewaremagic.com/weblogic/?tag=deploy#sthash.rTLTxQK3.dpuf
see http://middlewaremagic.com/weblogic/?tag=deploy
I figured it out.
I'm working on a Windows 7 machine and was using a linux command-line tool. I don't know the reason, but the linux console wasn't showing all my environment variables, as it couldn't find or read them, I don't know.
All works fine when I deploy from Windows CMD.

try finally in ant

In my ant script, which runs the end-to-end integration tests, I first start a process, then do some other stuff, then run the tests, and then I need to make sure I kill the process. However, I need to make sure I kill the process even if something fails (so I need an equivalent to try finally). What is the recommended way of doing it?
You could use Trycatch task from Antcontrib
<trycatch property="error.message">
<try>
<echo message="Run integration test..."/>
<echo message="Start process"/>
<antcall target="launchTests"/>
</try>
<catch>
<echo message="Integration test failed"/>
</catch>
<finally>
<echo message="Kill the process"/>
<exec executable="kill -9 ..."/>
</finally>
</trycatch>

How to make javac compiler write the output to both file and console?

I am running javac task using ant and I send the output to a log file using -Xstdout compiler argument for reporting purposes, but I would like the output also still being send to the console so hudson can capture it for on screen review.
Is there a way for this to be done?
Just came across another alternative using the recorder task.
Nearer as you don't have to introduce new targets.
<compile >
<record name="log.txt" action="start"/>
<javac ...
<record name="log.txt" action="stop"/>
<compile/>
use the ant task with an output attribute to call a target that has the javac task.
e.g.
<target name="javac" depends="libs" description="Compile java source">
<mkdir dir="${classes.dir}" />
<ant target="actual-javac" output="javac.log"/>
</target>
<target name="actual-javac">
<javac .../>
</javac>
</target>
you can use tee on any process on the command line to output to the console and a file:
>myprocess.sh | tee myprocess.log
will print the output of myprocess.sh both to the console and myprocess.log.

Resources