Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's wrong with these Ant/JVM args?

I am trying to run JBoss TattleTale from an Ant buildfile. Usually I run it from the commandline like so:

java -Xmx512m -jar /home/myuser/jars/tattletale.jar /home/myuser/projects/lib /home/myuser/tmp/tt

where /home/myuser/projects/src is the source directory where all my JARs are, and where /home/myuser/tmp/tt is the output directory where I place all of TattleTale's reports.

In the Ant buildfile I am using the following:

<echo message="Running tattle-tale..."/>
<java fork="true" failonerror="true" jar="/home/myuser/jars/tattletale.jar">
    <arg value="Xmx512m"/>
    <arg value="/home/myuser/projects/lib"/>
    <arg value="/home/myuser/tmp/tt"/>
</java>

When I run this target from the commandline:

run-tattletale:
    [echo] Running tattle-tale...

BUILD SUCCESSFUL
Total time: 3 seconds

When I go to /home/myuser/tmp/tt I don't see any output, however the Ant output shows SUCCESS with no errors or warnings. Do my <arg>s look correct, and if not, how should I change them? If they do look correct, what can I do to debug? Thanks in advance!

like image 600
IAmYourFaja Avatar asked Oct 14 '12 15:10

IAmYourFaja


Video Answer


3 Answers

Two things:

  1. Try using the debug option when running Ant, and save the output into a logfile. Then look at the log file. It will show you how it is executing the Java command. That will help you figure out where the Ant <java> is differing from the way you run Java directly from the command line. It'll give you the ability to tweek your <java> task.

  2. When a parameter is for the java command itself, you use <jvmarg> and not <arg>:

An example:

<echo message="Running tattle-tale..."/>
<java fork="true"
    failonerror="true"
    jar="/home/myuser/jars/tattletale.jar">
    <jvmarg value="-Xmx512m"/>  <!-- Note the dash! -->
    <arg value="/home/myuser/projects/lib"/>
    <arg value="/home/myuser/tmp/tt"/>
</java>

Try that, and run with ant -d | tee ant.out if you're on Unix/Linux. On Windows, you'll have to do ant -d > ant.out.txt which will save the output in ant.out.txt, but won't display the output while ant is running.

like image 125
David W. Avatar answered Oct 05 '22 00:10

David W.


The first args is a JVM argument not a program argument so <arg> is the wrong syntax. For this case it's easier to use the maxmemory parameter of the java task.

So remove the first <arg> and put maxmemory=512m in the <java> block.

like image 35
Mike Q Avatar answered Oct 04 '22 23:10

Mike Q


If you see no output in target directory, it may be due to 1) there is no archive in given input directory or 2) tattletale process is failing. In case of failure or exception, tattletale process seems returning exit code 0 and it makes ant believe that the process execution is successful.

For debugging, I suggest you to ensure given directory is correct and has java archive (jar) files and analyze the standard output/errors produced by tattletale.

Example:

<echo message="Running tattle-tale..."/>
<java fork="true"
    failonerror="false" 
    errorproperty="errorproperty"
    outputproperty="outputproperty"
    jar="/home/myuser/jars/tattletale.jar">
    <jvmarg value="-Xmx512m"/>  <!-- Note the dash! -->
    <arg value="/home/myuser/projects/lib"/>
    <arg value="/home/myuser/tmp/tt"/>
</java>
<echo message="stdout>> ${outputproperty}"/>
<echo message="stderr>> ${errorproperty}" /> 

Note:- failonerror is false temporarily for debugging purpose only.

like image 37
skadya Avatar answered Oct 05 '22 01:10

skadya