Problem with Asant Create-War

Posted on 2005-04-19
Last Modified: 2007-12-19
I've been building and deploying applications using a GUI tool for some time now, but I'm curious as to do it manually.

I have the J2EE tutorial from

If you go to Chapter 3, the one of the first notches called packaging web modules, it goes through how to build and package with asant.  Well, asant (or asant build) work just fine on the j2eetutorial14/examples/web/hello1 example they give, but when I do the next step, package it into a war, I type asant create-war in the cmd prompt and get this error:


Targer 'create-war' does not exist on this project.

This is the build.xml it came with:

 * Copyright (c) 2003 Sun Microsystems, Inc.  All rights reserved.  U.S.
 * Government Rights - Commercial software.  Government users are subject
 * to the Sun Microsystems, Inc. standard license agreement and
 * applicable provisions of the FAR and its supplements.  Use is subject
 * to license terms.  
 * This distribution may include materials developed by third parties.
 * Sun, Sun Microsystems, the Sun logo, Java and J2EE are trademarks
 * or registered trademarks of Sun Microsystems, Inc. in the U.S. and
 * other countries.  
 * Copyright (c) 2002 Sun Microsystems, Inc. Tous droits reserves.
 * Droits du gouvernement americain, utilisateurs gouvernementaux - logiciel
 * commercial. Les utilisateurs gouvernementaux sont soumis au contrat de
 * licence standard de Sun Microsystems, Inc., ainsi qu'aux dispositions
 * en vigueur de la FAR (Federal Acquisition Regulations) et des
 * supplements a celles-ci.  Distribue par des licences qui en
 * restreignent l'utilisation.
 * Cette distribution peut comprendre des composants developpes par des
 * tierces parties. Sun, Sun Microsystems, le logo Sun, Java et J2EE
 * sont des marques de fabrique ou des marques deposees de Sun
 * Microsystems, Inc. aux Etats-Unis et dans d'autres pays.

<!DOCTYPE project [
  <!ENTITY targets SYSTEM "../../common/targets.xml">
  <!ENTITY webtargets SYSTEM "../common/targets.xml">

<project name="hello1-example" default="build" basedir=".">
  <target name="init">

  <property name="example" value="hello1" />

  <property file="../../common/"/>
  <property file="../common/"/>


  <target name="build" depends="copy"
     description="Compile app Java files and copy HTML and JSP pages" >
    <mkdir dir="${build}/WEB-INF" />
    <copy todir="${build}/WEB-INF">
      <fileset dir="web">
        <include name="**/*.xml" />


Does anyone know why it's doing this?  Also, I know this is an example they give, but in the future, do you have to create your own build.xml?  And if not, are there tools out there to help build your deployment descriptors, i.e. web.xml and ejb-jar.xml?


Question by:gdlp2004
    LVL 15

    Expert Comment

    I think you have this line wrong:
    <!ENTITY webtargets SYSTEM "../common/targets.xml">
    probably it should be <!ENTITY webtargets SYSTEM "../common/webtargets.xml">

    The 'create-war' target is not part of the build.xml but should be included (by calling &webtargets)

    Eclipse IDE can help you with both ant build files as well as web/ejb-jar xml files.

    Author Comment

    Didn't work.  I looked in the common folder and it is names targets.xml like it should.
    LVL 15

    Expert Comment

    you should have a file named webtargest.xml in the common folder (in addition to targets.xml)?
    that file should contain the 'create-war' target.

    Author Comment

    in this example, all I have is a and targets.xml in the common folder.  This is an example included in the tutorial bundle.
    LVL 15

    Accepted Solution

    Right, I download the example to check that.
    <!DOCTYPE project [
      <!ENTITY targets SYSTEM "../../common/targets.xml">
      <!ENTITY webtargets SYSTEM "../common/targets.xml">
    as it was before.
    You need to run the build.xml (e.g ant build.xml) from the hello1 directory
    The includes are relative to where you are running it from.
    and the 'create-war' task is located at examples\web\common\targets.xml

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    Title # Comments Views Activity
    maxMirror challenge 10 68
    countClumps  challenge 10 68
    parentbit challenge 3 37
    word0 challenge 4 37
    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now