facebook

Problems validating web.xml files

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #247084 Reply

    Jeff Smith
    Member

    The problem that I am having is the red X on the </web-app> tag on my web.xml file. I have spent quit a bit of time on the net searching for an answer and have been unsuccessful. I know that there has to be an extremely easy answer to this that I have not been able to find. I am new to this and am just trying to figure it out. Thanks in advance,
    Jeff

    The first error that I am receiving is:

    “cvc-complex-type.2.3: Element ‘web-app’ cannot have character [children], because the type’s content type is element-only.”

    <?xml version=”1.0″?>

    <web-app xmlns=”http://java.sun.com/xml/ns/j2ee&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&#8221;
    version=”2.4″>

    <display-name>Homework 2 Quiz</display-name>
    – <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>

    – <servlet>
    <servlet-name>Question_1</servlet-name>
    <jsp-file>/Question_1.jsp</jsp-file>
    </servlet>

    – <servlet-mapping>
    <servlet-name>Question_1</servlet-name>
    <url-pattern>/Question_1</url-pattern>
    </servlet-mapping>

    </web-app>

    The second issue that I am having is with the file configured as follows I get this error:
    (different project but same issue)

    The content of element type “web-app” must match “(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,
    listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,
    error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,
    security-role*,env-entry*,ejb-ref*,ejb-local-ref*)”.

    <?xml version=”1.0″ encoding=”ISO-8859-1″?>

    <!DOCTYPE web-app
    PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”
    http://java.sun.com/dtd/web-app_2_3.dtd”&gt;

    <web-app>
    <display-name>State Capitals Quiz</display-name>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>

    <servlet>
    <servlet-name>Question_1</servlet-name>
    <jsp-file>/Question_1.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Question_2</servlet-name>
    <jsp-file>/Question_2.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Question_3</servlet-name>
    <jsp-file>/Question_3.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Question_4</servlet-name>
    <jsp-file>/Question_4.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Question_5</servlet-name>
    <jsp-file>/Question_5.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Question_6</servlet-name>
    <jsp-file>/Question_6.jsp</jsp-file>
    </servlet>

    <servlet-mapping>
    <servlet-name>Question_1</servlet-name>
    <url-pattern>/Question_1</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Question_2</servlet-name>
    <url-pattern>/Question_2</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Question_3</servlet-name>
    <url-pattern>/Question_3</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Question_4</servlet-name>
    <url-pattern>/Question_4</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Question_5</servlet-name>
    <url-pattern>/Question_5</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Question_6</servlet-name>
    <url-pattern>/Question_6</url-pattern>
    </servlet-mapping>
    </web-app>

    *** Date: Mon Feb 20 12:32:44 EST 2006

    *** System properties:
    OS=WindowsXP
    OS version=5.1
    Java version=1.5.0_06

    *** MyEclipse details:
    MyEclipse Enterprise Workbench

    Version: 4.1.0 GA
    Build id: 20060122-4.1-GA

    *** Eclipse details:
    Eclipse SDK

    Version: 3.1.1
    Build id: M20050929-0840

    Eclipse Platform

    Version: 3.1.1
    Build id: M20050929-0840

    Eclipse RCP

    Version: 3.1.1
    Build id: M20050929-0840

    Eclipse Java Development Tools

    Version: 3.1.1
    Build id: M20050929-0840

    Eclipse Plug-in Development Environment

    Version: 3.1.1
    Build id: M20050929-0840

    Eclipse Project SDK

    Version: 3.1.1
    Build id: M20050929-0840

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86
    -launcher
    C:\JAVA\eclipse\eclipse.exe
    -name
    Eclipse
    -showsplash
    600
    -exitdata
    9d8_38
    -vm
    C:\JAVA\jdk1.5.0_06\bin\javaw.exe

    This was a fresh install of both Eclipse and myEclipse

    I am using JBOSS 4.0.3SP1

    #247085 Reply

    Riyad Kalla
    Member

    Your web.xml file is invalid not only that, you pasted the header of two separate files, so I’m not sure which one is the problem.

    Do me a favor, copy and paste the entire web.xml file that you are having trouble into a new message all by itself, then paste the error(s) into another message. I have a feeling this issue is as simple as you declaring a 2.4 web.xml file in a 2.3 project or visa versa (the difference is the 2.3 used the DTD and the 2.4 now uses the schema file, there were slight structure changes between the two but J2EE 1.3 uses 2.3 spec and J2EE 1.4 uses the 2.4 web spec, you might have mixed these up especially if you are straight copy-pasting from a tutorial into your project)

    #247089 Reply

    Jeff Smith
    Member

    <?xml version=”1.0″ encoding=”ISO-8859-1″?>

    <!DOCTYPE web-app
    PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”
    http://java.sun.com/dtd/web-app_2_3.dtd”&gt;

    <web-app>
    <display-name>State Capitals Quiz</display-name>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>

    <servlet>
    <servlet-name>Question_1</servlet-name>
    <jsp-file>/Question_1.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Question_2</servlet-name>
    <jsp-file>/Question_2.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Question_3</servlet-name>
    <jsp-file>/Question_3.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Question_4</servlet-name>
    <jsp-file>/Question_4.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Question_5</servlet-name>
    <jsp-file>/Question_5.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Question_6</servlet-name>
    <jsp-file>/Question_6.jsp</jsp-file>
    </servlet>

    <servlet-mapping>
    <servlet-name>Question_1</servlet-name>
    <url-pattern>/Question_1</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Question_2</servlet-name>
    <url-pattern>/Question_2</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Question_3</servlet-name>
    <url-pattern>/Question_3</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Question_4</servlet-name>
    <url-pattern>/Question_4</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Question_5</servlet-name>
    <url-pattern>/Question_5</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Question_6</servlet-name>
    <url-pattern>/Question_6</url-pattern>
    </servlet-mapping>
    </web-app>

    #247090 Reply

    Jeff Smith
    Member

    The content of element type “web-app” must match “(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,
    listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,
    taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,
    ejb-ref*,ejb-local-ref*)”.

    #247100 Reply

    Riyad Kalla
    Member

    Ahh, welcome-file-list section needs to be at the end of your file. All much of gibberish as that error messages looks like, notice how “welcome-file-list?” comes after the “servlet*” and “servlet-mapping*” entries? Your xml file is out of order.

    #247106 Reply

    Jeff Smith
    Member

    Thank you, while searching for an answer to this yesterday I came across a post at the sun site that said the same thing. I tried putting things in order and it didn’t fix the problem. Good news is that it has fixed it today. I hate being the newbie, it is always so full of problems.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Problems validating web.xml files

You must be logged in to post in the forum log in