IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ANT Java Discussion :

[ANT]Generation de war


Sujet :

ANT Java

  1. #1
    Membre averti
    Inscrit en
    Mai 2006
    Messages
    41
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 41
    Par défaut [ANT]Generation de war
    Bonjour,
    j'ai parcouru le forum et google, mais je ne parviens pas a générer une archive war pour mon application qui utilise struts....

    voici l'arborescence de mon projet:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    +images
    -pages
         +tiles
    -WEB-INF
         +classes
         +lib
         +src
         web.xml
         tiles-defs.xml
         struts-config.xml etc...
    je veus pouvoir deployer correctement mon application sous Jboss AS, et pour cela il me faut créer une archive war. J'ai donc installé ant, mais je n'arrive pas a construire mon build.xml comme il faut pour que ca marche,
    voila a quoi il resemble pour le moment suivit de l'erreur que j'ai au lancement de la tache.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <war destfile="sortie.war" webxml="oreli\WEB-INF\web.xml">
    <fileset dir="oreli\WEB-INF\src">
    <fileset dir="oreli\pages">
    <fileset dir="oreli\images">
    </fileset>
    <classes dir="oreli\WEB-INF\classes">
    </war>
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
     
    E:\Programmation\3eme Année>ant -debug
    Apache Ant version 1.7.0 compiled on December 13 2006
    Buildfile: build.xml
    Adding reference: ant.PropertyHelper
    Detected Java version: 1.5 in: C:\Program Files\Java\jdk1.5.0_10\jre
    Detected OS: Windows XP
    Adding reference: ant.ComponentHelper
    Setting ro project property: ant.file -> E:\Programmation\3eme AnnÚe\build.xml
    Adding reference: ant.projectHelper
    Adding reference: ant.parsing.context
    Adding reference: ant.targets
    parsing buildfile E:\Programmation\3eme AnnÚe\build.xml with URI = file:/E:/Prog
    rammation/3eme%20Ann%C3%A9e/build.xml
     
    BUILD FAILED
    E:\Programmation\3eme AnnÚe\build.xml:2: Unexpected element "{}war" {antlib:org.
    apache.tools.ant}war
            at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:
    225)
            at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:
    138)
            at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.jav
    a:96)
            at org.apache.tools.ant.Main.runBuild(Main.java:683)
            at org.apache.tools.ant.Main.startAnt(Main.java:199)
            at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
            at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
    Caused by: org.xml.sax.SAXParseException: Unexpected element "{}war" {antlib:org
    .apache.tools.ant}war
            at org.apache.tools.ant.helper.ProjectHelper2$MainHandler.onStartChild(P
    rojectHelper2.java:626)
            at org.apache.tools.ant.helper.ProjectHelper2$RootHandler.startElement(P
    rojectHelper2.java:521)
            at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Sour
    ce)
            at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unkn
    own Source)
            at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.s
    canRootElementHook(Unknown Source)
            at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
    Dispatcher.dispatch(Unknown Source)
            at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
    known Source)
            at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
            at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
            at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
            at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
            at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Sour
    ce)
            at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:
    209)
            ... 6 more
    --- Nested Exception ---
    org.xml.sax.SAXParseException: Unexpected element "{}war" {antlib:org.apache.too
    ls.ant}war
            at org.apache.tools.ant.helper.ProjectHelper2$MainHandler.onStartChild(P
    rojectHelper2.java:626)
            at org.apache.tools.ant.helper.ProjectHelper2$RootHandler.startElement(P
    rojectHelper2.java:521)
            at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Sour
    ce)
            at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unkn
    own Source)
            at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.s
    canRootElementHook(Unknown Source)
            at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
    Dispatcher.dispatch(Unknown Source)
            at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
    known Source)
            at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
            at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
            at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
            at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
            at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Sour
    ce)
            at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:
    209)
            at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:
    138)
            at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.jav
    a:96)
            at org.apache.tools.ant.Main.runBuild(Main.java:683)
            at org.apache.tools.ant.Main.startAnt(Main.java:199)
            at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
            at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
     
    Total time: 0 seconds
    merci de m'aider a compléter mon script pour résoudre ce problème

    Aswat

  2. #2
    Membre averti
    Inscrit en
    Mai 2006
    Messages
    41
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 41
    Par défaut
    j'ai sur les conseils d'autres personnes, modifié mon build.xml qui resemble maintenant à ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <project name="oreli" basedir="E:/Programmation/3eme Année">
    	<property name="project" value="oreli"/>
    	<property name="dist" value="oreli/WEB-INF/classes/"/>
    	<property name="src" value="oreli/WEB-INF/src/"/>
    	<target name="create-war">
    		<delete file="${project}.war"/>
    		<war destfile="${project}.war" webxml="oreli/WEB-INF/web.xml">
    			<fileset dir="oreli/pages/"/>
    			<lib dir="oreli/WEB-INF/lib"/>
    			<classes dir="${dist}">
    				<include name="**/*.class"/>
    			</classes>
    			<zipfileset dir="oreli/images/" prefix="img"/>
    		</war>
    	</target>
    </project>
    mais ca ne génère rien et me sort ca en mode debug :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    E:\Programmation\3eme Année>ant -debug
    Apache Ant version 1.7.0 compiled on December 13 2006
    Buildfile: build.xml
    Adding reference: ant.PropertyHelper
    Detected Java version: 1.5 in: C:\Program Files\Java\jdk1.5.0_10\jre
    Detected OS: Windows XP
    Adding reference: ant.ComponentHelper
    Setting ro project property: ant.file -> E:\Programmation\3eme AnnÚe\build.xml
    Adding reference: ant.projectHelper
    Adding reference: ant.parsing.context
    Adding reference: ant.targets
    parsing buildfile E:\Programmation\3eme AnnÚe\build.xml with URI = file:/E:/Prog
    rammation/3eme%20Ann%C3%A9e/build.xml
    Setting ro project property: ant.project.name -> oreli
    Adding reference: oreli
    Setting ro project property: ant.file.oreli -> E:\Programmation\3eme AnnÚe\build
    .xml
    Project base dir set to: E:\Programmation\3eme AnnÚe
     +Target:
     +Target: create-war
    [antlib:org.apache.tools.ant] Could not load definitions from resource org/apach
    e/tools/ant/antlib.xml. It could not be found.
    Setting project property: project -> oreli
    Setting project property: dist -> oreli/WEB-INF/classes/
    Setting project property: src -> oreli/WEB-INF/src/
    Attempting to create object of type org.apache.tools.ant.helper.DefaultExecutor
    Adding reference: ant.executor
     
    BUILD SUCCESSFUL
    Total time: 0 seconds

  3. #3
    Membre à l'essai
    Inscrit en
    Mars 2007
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 5
    Par défaut
    À ta place, j'utiliserais les task <zipfileset> au lieu des tasks <fileset>, <lib> et <classes> à l'intérieur de ton task <war>, de cette façon:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    <war destfile="${project}.war" webxml="oreli/WEB-INF/web.xml">
    	<zipfileset dir="oreli/pages/" includes="**/*"/>
    	<zipfileset dir="oreli/WEB-INF/lib" prefix="WEB-INF/lib"/>
    	<zipfileset dir="${dist}" prefix="classes">
    		<include name="**/*.class"/>
    	</zipfileset>
    	<zipfileset dir="oreli/images/" prefix="img"/>
    </war>
    Même si dans la documentation de Ant on nous dit que les elements <lib> et <classes> sont permis je trouve beaucoup simple et fiable d'utiliser des <zipfileset> et de spécifier moi-même ou les fichiers vont aller dans le package en utilisant l'attribut prefix=""

  4. #4
    Membre averti
    Inscrit en
    Mai 2006
    Messages
    41
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 41
    Par défaut
    merci pour ton aide,
    je suis parvenu a faire un build.xml correcte :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    <project name="blank" basedir="../" default="all">
     
     
        <!-- Local system paths -->
        <property name="servlet.jar" value="./libext/servlet-api.jar"/>
        <property name="jdbc20ext.jar" value="./libext/jdbc2_0-stdext.jar"/>
    	<property name="mysql-connector-java-3.0.16-ga-bin.jar" value="./libext/mysql-connector-java-3.0.16-ga-bin.jar"/>
            <!-- NOTE: If "dist" target is used, a local
                 "projects/lib" directory will be utilized or created -->
        <property name="distpath.project" value="../../dist"/>
     
     
        <!-- Project settings -->
        <property name="project.title" value="Notre projet de fin d'etudes"/>
        <property name="project.distname" value="oreli"/>
        <property name="project.version" value="1.1"/>
     
     
        <!-- Path settings -->
        <property name="doc.path" value="./doc/api"/>
        <property name="doc.src" value="./src/java"/>
     
     
        <!-- classpath for Struts 1.1 -->
        <path id="compile.classpath">
            <pathelement path ="./lib/commons-beanutils.jar"/>
            <pathelement path ="./lib/commons-digester.jar"/>
            <pathelement path ="./lib/struts.jar"/>
            <pathelement path ="classes"/>
            <pathelement path ="${classpath}"/>
        </path>
     
      <path id="class.path">
        <fileset dir="lib">
          <include name="**/*.jar"/>
        </fileset>
        <fileset dir="libext">
          <include name="**/*.jar"/>
        </fileset>
      </path>
     
     
        <!-- Check timestamp on files -->
        <target name="prepare">
            <tstamp/>
        </target>
     
     
        <!-- Copy any resource or configuration files -->
        <target name="resources">
            <copy todir="classes" includeEmptyDirs="no">
                <fileset dir="src/java">
                <patternset>
                    <include name="**/*.conf"/>
                    <include name="**/*.properties"/>
                    <include name="**/*.xml"/>
                </patternset>
                </fileset>
            </copy>
        </target>
     
     
        <!-- Normal build of application -->
        <target name="compile" depends="prepare,resources">
            <javac srcdir="src" destdir="classes">
                <!--<classpath refid="compile.classpath"/>-->
    			<classpath refid="class.path"/>
            </javac>
        </target>
     
     
        <!-- Remove classes directory for clean build -->
        <target name="clean"
          description="Prepare for clean build">
          <delete dir="classes"/>
          <mkdir  dir="classes"/>
        </target>
     
     
        <!-- Build Javadoc documentation -->
        <target name="javadoc"
         description="Generate JavaDoc API docs">
            <delete dir="./doc/api"/>
            <mkdir dir="./doc/api"/>
            <javadoc sourcepath="./src/java"
                destdir="./doc/api"
                classpath="${servlet.jar}:${jdbc20ext.jar}"
                packagenames="*"
                author="true"
                private="true"
                version="true"
                windowtitle="${project.title} API Documentation"
                doctitle="&lt;h1&gt;${project.title} Documentation (Version ${project.version})&lt;/h1&gt;"
                bottom="Copyright © 2002">
                <classpath refid="compile.classpath"/>
            </javadoc>
        </target>
     
     
        <!-- Build entire project -->
        <target name="project" depends="clean,prepare,compile"/>
     
     
        <!-- Create binary distribution -->
        <target name="dist"
            description="Create binary distribution">
     
          <mkdir
            dir="${distpath.project}"/>
          <jar
            jarfile="${distpath.project}/${project.distname}.jar"
            basedir="./classes"/>
          <copy
            file="${distpath.project}/${project.distname}.jar"
            todir="${distpath.project}"/>
     
          <war
            basedir="../"
            warfile="${distpath.project}/${project.distname}.war"
            webxml="web.xml">
            <exclude name="${distpath.project}/${project.distname}.war"/>
           </war>
     
        </target>
     
     
        <!-- Build project and create distribution-->
        <target name="all" depends="project,dist"/>
     
    </project>

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Hibernate, Ant : generation automatique
    Par L'ours dans le forum Hibernate
    Réponses: 3
    Dernier message: 22/10/2008, 15h54
  2. Eclipse et jboss probleme generation du war
    Par ensisoft dans le forum Wildfly/JBoss
    Réponses: 1
    Dernier message: 03/04/2008, 13h35
  3. Réponses: 0
    Dernier message: 23/11/2007, 20h13
  4. Generation de war
    Par jpclavery dans le forum Maven
    Réponses: 7
    Dernier message: 28/09/2007, 15h05
  5. [Plugin][Ant]Generation automatique de build.xml
    Par matta dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 14/01/2005, 09h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo