• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 658
  • Last Modified:

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 http://java.sun.com/j2ee/1.4/docs/tutorial/doc/

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:

BUILD FAILED

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">
      <tstamp/>
  </target>


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

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

  &targets;
  &webtargets;

  <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" />
      </fileset>
    </copy>
  </target>

 
 </project>


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?

Thanks!



0
gdlp2004
Asked:
gdlp2004
  • 3
  • 2
1 Solution
 
aozarovCommented:
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.
0
 
gdlp2004Author Commented:
Didn't work.  I looked in the common folder and it is names targets.xml like it should.
0
 
aozarovCommented:
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.
0
 
gdlp2004Author Commented:
in this example, all I have is a build.properties and targets.xml in the common folder.  This is an example included in the tutorial bundle.
0
 
aozarovCommented:
Right, I download the example to check that.
keep:
<!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
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now