Error: cvc-elt.1.a: Cannot find the declaration of element 'web-app'

Comment résoudre l'erreur : cvc-elt.1.a : Impossible de trouver la déclaration de l’élément 'web-app'.
Cette erreur est souvent générée en java lors de la création du projet ou la création du fichier web.xml avec eclipse. Comment résoudre l'erreur : cvc-elt.1.a : Impossible de trouver la déclaration de l’élément 'web-app'.


cvc-elt.1.a: Cannot find the declaration of element 'web-app'

Si vous utilisez une nouvelle version de Tomcat ou une autre application serveur Java, vérifiez s’ils fonctionnent avec un nouveau package jakarta ou un ancien package javax.Tomcat 10 est déjà migré vers Jakarta EE, donc si vous utilisez Tomcat 10, vous pouvez utiliser la déclaration doctype jakarta mentionnée ci-dessous. 

Déclaration correcte pour l’ancienne version du paquet javax .  

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> 
Déclaration correcte pour la nouvelle version du package jakarta.

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="5.0">
Eclipse IDE for Enterprise Java and Web Developers

Une astuce existe est celle de complètement supprimer cette expression: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"

Vous aurez un résultat similaire à la capture ci-dessous: 




Laissez un commentaire si cela a fonctionné pour vous. Version tomcat 9 ou 10,etc.






0 Commentaires