Problem with Asant Create-War

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?


Who is Participating?
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
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.
gdlp2004Author Commented:
Didn't work.  I looked in the common folder and it is names targets.xml like it should.
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.
gdlp2004Author Commented:
in this example, all I have is a and targets.xml in the common folder.  This is an example included in the tutorial bundle.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.