What's wrong with these Ant/JVM args?
Asked Answered
D

3

5

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!

Doridoria answered 14/10, 2012 at 15:52 Comment(0)
D
6

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.

Dimpledimwit answered 14/10, 2012 at 19:13 Comment(0)
E
3

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.

Er answered 14/10, 2012 at 16:1 Comment(1)
Thanks @Mike Q (+1) - but I'm still not seeing anything being generated in the output directory.Doridoria
M
1

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.

Millihenry answered 22/12, 2016 at 20:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.