[ANT] error: package javax.servlet does not exist
Bonjour à tous,
J'ai utilisé la fonction recherche, je suis tombé sur plusieurs sujets traitant de mon soucis mais malheureusement je n'ai pas réussi à le solutionner car je ne maitrise pas bien les notions de classpath etc ....
Mon projet fonctionne parfaitement via Eclipse en copiant mes JSP vers le web-content mais lorsque je veux buidler tout ça avec la compilation au passage, ça ne fonctionne pas.
Mon build.xml :
Code:
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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
| <project name="curostoc_2012_trunk" default="build_war" basedir=".">
<!-- ===================================== -->
<!-- ===================================== -->
<!-- Definition des varaibles -->
<!-- ===================================== -->
<!-- ===================================== -->
<!-- repertoire d'installation de tomcat -->
<property name="tomcat_dir" value="C:\Program Files\Apache Software Foundation\Tomcat 6.0" />
<!-- nom du projet -->
<property name="project-name" value="curostoc_2012_trunk" />
<!-- reference le projet eclipse -->
<property name="project-dir" location=".." />
<!-- defini le nom du war qui est genere -->
<property name="war-file-name" value="${project-name}.war" />
<!-- repertoire des sources java -->
<property name="source-directory" value="${project-dir}\src" />
<!-- repertoire des libs -->
<property name="lib_lib" value="${project-dir}\lib"/>
<!-- repertoire des sources jsp -->
<property name="jsp-directory" value="${project-dir}\jsp" />
<!-- repertoire des sources css -->
<property name="css-directory" value="${project-dir}\style" />
<!-- repertoire des sources img -->
<property name="img-directory" value="${project-dir}\img" />
<!-- repertoire des scripts -->
<property name="script-directory" value="${project-dir}\sh" />
<!-- repertoire de build -->
<property name="build-directory" value="${project-dir}\war" />
<!-- repertoire des sources de type resources -->
<property name="res-directory" value="${project-dir}\resources" />
<!-- repertoir de base de l'arborescence du war -->
<property name="web-directory" value="${project-dir}\WebContent" />
<!-- fichier web.xml -->
<property name="web-xml-file" value="${web-directory}\WEB-INF\web.xml" />
<!-- repertoire lib du war -->
<property name="war-lib" value="${web-directory}\WEB-INF\lib" />
<!-- repertoire classes du war -->
<property name="war-classes" value="${web-directory}\WEB-INF\classes" />
<!-- repertoire des jsp du war -->
<property name="war-jsp" value="${web-directory}\templates" />
<!-- repertoire des img du war -->
<property name="war-img" value="${web-directory}\img" />
<!-- repertoire du style du war -->
<property name="war-css" value="${web-directory}\style" />
<!-- repertoire du manifest -->
<property name="war-manifest" value="${web-directory}\META-INF" />
<!-- ===================================== -->
<!-- ===================================== -->
<!-- Fin de Definition des varaibles -->
<!-- ===================================== -->
<!-- ===================================== -->
<!-- affichage des variables -->
<!-- pour exemple -->
<target name="affiche" description="affiche les variables">
<echo>=========================================</echo>
<echo>========affichage de variables ==========</echo>
<echo>=========================================</echo>
<echo>tomcat_dir=${tomcat_dir}</echo>
<echo>=========================================</echo>
<echo>=========================================</echo>
<echo>=========================================</echo>
</target>
<!-- Nettoyage -->
<target name="clean" description="Nettoyage des repertoires du war">
<delete includeEmptyDirs="true">
<fileset dir="${war-jsp}" includes="*"/>
<fileset dir="${war-lib}" includes="*"/>
<fileset dir="${war-classes}" includes="**/*"/>
<fileset dir="${war-manifest}" includes="*"/>
<fileset dir="${war-jsp}\connexion" includes="*"/>
<fileset dir="${war-jsp}\couleur" includes="*"/>
<fileset dir="${war-jsp}\intervention" includes="*"/>
<fileset dir="${war-jsp}\projet" includes="*"/>
<fileset dir="${war-jsp}\type_intervention" includes="*"/>
<fileset dir="${war-jsp}\utilisateur" includes="*"/>
<fileset dir="${war-jsp}\planification" includes="*"/>
<fileset dir="${war-jsp}\reserve" includes="*"/>
<fileset dir="${war-jsp}\technicien" includes="*"/>
<fileset dir="${war-jsp}\survey" includes="*"/>
<fileset file="${war-manifest}/MANIFEST.MF" />
<fileset file="${web-xml-file}" />
</delete>
<delete file="${build-directory}/${war-file-name}" />
</target>
<!-- deploiement -->
<target name="deploiement" description="Publie le war sur tomcat">
<!-- copy du war dans le root app de tomcat -->
<copy todir="${tomcat_dir}\webapps">
<fileset file="${build-directory}\${war-file-name}"/>
</copy>
<!-- arret du service -->
<apply executable="cmd" >
<arg value="/C" />
<arg value="${script-directory}\stopTomcat.bat"/>
<fileset file="*"/>
</apply>
<!-- destruction des logs par securite -->
<delete>
<fileset dir="${tomcat_dir}\logs" includes="*"/>
</delete>
<!-- destruction du repertoire de l'application web -->
<!-- normalement non necessaire -->
<delete dir="${tomcat_dir}\webapps\${project-name}"/>
<!-- demarrage du service -->
<apply executable="cmd" >
<arg value="/C" />
<arg value="${script-directory}\startTomcat.bat"/>
<fileset file="*"/>
</apply>
</target>
<!-- compilation des fichiers java -->
<target name="build_java" description="compilaction des fichiers java">
<javac srcdir="${source-directory}" destdir="${war-classes}" />
</target>
<!-- target par defaut -->
<target name="build_war" depends="">
<!-- affichage de variables pour information -->
<antcall target="affiche" />
<!-- nettoyage par precaution -->
<antcall target="clean" />
<!-- creation du repertoire de build pour la premiere fois -->
<mkdir dir="${build-directory}" />
<!-- copie des fichiers de properties -->
<copy todir="${war-classes}">
<fileset dir="${source-directory}" excludes="**/*.java"/>
</copy>
<copy todir="${war-classes}">
<fileset file="${source-directory}\connexion\db.properties"/>
</copy>
<!-- copie des libs des dependances dans le war -->
<copy todir="${war-lib}">
<fileset file="${lib_lib}\*.jar" />
</copy>
<!-- copie des jsp dans TEMPLATES -->
<copy todir="${war-jsp}">
<fileset file="${jsp-directory}\templates\*" />
</copy>
<copy todir="${war-jsp}\connexion">
<fileset file="${jsp-directory}\templates\connexion\*" />
</copy>
<copy todir="${war-jsp}\couleur">
<fileset file="${jsp-directory}\templates\couleur\*" />
</copy>
<copy todir="${war-jsp}\intervention">
<fileset file="${jsp-directory}\templates\intervention\*" />
</copy>
<copy todir="${war-jsp}\projet">
<fileset file="${jsp-directory}\templates\projet\*" />
</copy>
<copy todir="${war-jsp}\type_intervention">
<fileset file="${jsp-directory}\templates\type_intervention\*" />
</copy>
<copy todir="${war-jsp}\utilisateur">
<fileset file="${jsp-directory}\templates\utilisateur\*" />
</copy>
<copy todir="${war-jsp}\planification">
<fileset file="${jsp-directory}\templates\planification\*" />
</copy>
<copy todir="${war-jsp}\reserve">
<fileset file="${jsp-directory}\templates\reserve\*" />
</copy>
<copy todir="${war-jsp}\technicien">
<fileset file="${jsp-directory}\templates\technicien\*" />
</copy>
<copy todir="${war-jsp}\survey">
<fileset file="${jsp-directory}\templates\survey\*" />
</copy>
<!-- copie des jsp index et main -->
<copy todir="${web-directory}">
<fileset file="${jsp-directory}\index.jsp"/>
<fileset file="${jsp-directory}\main.jsp"/>
</copy>
<copy todir="${web-directory}\templates">
<fileset file="${jsp-directory}\templates\home.jsp"/>
<fileset file="${jsp-directory}\templates\menu.jsp"/>
</copy>
<!-- copie du manifest -->
<copy todir="${war-manifest}">
<fileset file="${res-directory}\MANIFEST.MF" />
</copy>
<!-- copie du style -->
<copy todir="${war-css}">
<fileset file="${css-directory}\*.css" />
</copy>
<!-- copie des img -->
<copy todir="${war-img}">
<fileset file="${img-directory}\*.png" />
</copy>
<!-- copie du fichier de configuration de l'application web -->
<copy todir="${web-directory}\WEB-INF">
<fileset file="${res-directory}\web.xml" />
</copy>
<!-- compilation des classes -->
<antcall target="build_java"/>
<!-- creation du war -->
<war destfile="${build-directory}\${war-file-name}" webxml="${web-xml-file}">
<!--definition du lieu de classes -->
<classes dir="${war-classes}"/>
<!-- definition du lieu de lib -->
<lib dir="${war-lib}"/>
<!-- ajout du repertoire contenant les jsp -->
<zipfileset dir="${war-jsp}" prefix="templates/" />
<zipfileset dir="${war-img}" prefix="img/"/>
<zipfileset dir="${war-css}" prefix="style/"/>
<fileset file="${web-directory}\index.jsp"/>
<fileset file="${web-directory}\main.jsp"/>
</war>
<!-- deploiement du war -->
<antcall target="deploiement"/>
</target>
</project> |
Le résultat de mon build :
Code:
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
| Buildfile: C:\Users\Thiib-7\workspace\curostoc_trunk_2012\build\build.xml
build_war:
affiche:
[echo] =========================================
[echo] ========affichage de variables ==========
[echo] =========================================
[echo] tomcat_dir=C:\Program Files\Apache Software Foundation\Tomcat 6.0
[echo] =========================================
[echo] =========================================
[echo] =========================================
clean:
[copy] Copying 1 file to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\WEB-INF\classes
[copy] Copying 1 file to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\WEB-INF\classes
[copy] Copying 6 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\WEB-INF\lib
[copy] Copying 2 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates
[copy] Copying 2 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates\connexion
[copy] Copying 6 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates\couleur
[copy] Copying 9 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates\intervention
[copy] Copying 5 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates\projet
[copy] Copying 5 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates\type_intervention
[copy] Copying 5 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates\utilisateur
[copy] Copying 5 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates\planification
[copy] Copying 5 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates\reserve
[copy] Copying 5 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates\technicien
[copy] Copying 5 files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\templates\survey
[copy] Copying 1 file to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\WEB-INF
build_java:
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\build\build.xml:156: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 28 source files to C:\Users\Thiib-7\workspace\curostoc_trunk_2012\WebContent\WEB-INF\classes
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:8: error: package javax.servlet does not exist
[javac] import javax.servlet.RequestDispatcher;
[javac] ^
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:9: error: package javax.servlet does not exist
[javac] import javax.servlet.ServletException;
[javac] ^
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:10: error: package javax.servlet does not exist
[javac] import javax.servlet.ServletOutputStream;
[javac] ^
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:11: error: package javax.servlet.http does not exist
[javac] import javax.servlet.http.HttpServlet;
[javac] ^
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:12: error: package javax.servlet.http does not exist
[javac] import javax.servlet.http.HttpServletRequest;
[javac] ^
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:13: error: package javax.servlet.http does not exist
[javac] import javax.servlet.http.HttpServletResponse;
[javac] ^
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:16: error: cannot find symbol
[javac] public class ControleurServletDownload extends HttpServlet {
[javac] ^
[javac] symbol: class HttpServlet
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:26: error: cannot find symbol
[javac] protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
[javac] ^
[javac] symbol: class HttpServletRequest
[javac] location: class ControleurServletDownload
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:26: error: cannot find symbol
[javac] protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
[javac] ^
[javac] symbol: class HttpServletResponse
[javac] location: class ControleurServletDownload
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:26: error: cannot find symbol
[javac] protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
[javac] ^
[javac] symbol: class ServletException
[javac] location: class ControleurServletDownload
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:31: error: cannot find symbol
[javac] protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
[javac] ^
[javac] symbol: class HttpServletRequest
[javac] location: class ControleurServletDownload
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:31: error: cannot find symbol
[javac] protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
[javac] ^
[javac] symbol: class HttpServletResponse
[javac] location: class ControleurServletDownload
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:31: error: cannot find symbol
[javac] protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
[javac] ^
[javac] symbol: class ServletException
[javac] location: class ControleurServletDownload
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:42: error: cannot find symbol
[javac] ServletOutputStream out = response.getOutputStream();
[javac] ^
[javac] symbol: class ServletOutputStream
[javac] location: class ControleurServletDownload
[javac] C:\Users\Thiib-7\workspace\curostoc_trunk_2012\src\controleur\ControleurServletDownload.java:80: error: cannot find symbol
[javac] RequestDispatcher dispatch = request.getRequestDispatcher("/index.jsp?page=intervention&action=visualisation&id="+id);
[javac] ^
[javac] symbol: class RequestDispatcher
[javac] location: class ControleurServletDownload
[javac] 15 errors |
Ci-dessous mon organisation sous Eclipse.
http://img96.imageshack.us/img96/541...ctrunk2012.jpg
J'ai bien dans mon dossier /lib les lib servlet-api.jar javax-servlet ....
Auriez-vous une idée svp ?
Merci d'avance,