9 Replies Latest reply on Mar 15, 2005 9:21 AM by 807567

    HELP: "web-app" does not allow "filter"

    807567
      Here is my web.xml, but everytime I tried to start the web server 6.1, it complains:
      info: CORE3282: stdout: PARSE error at line 108 column -1
      info: CORE3282: stdout: org.xml.sax.SAXParseException: Element "web-app" does not allow "filter" here.
      failure: ContextConfig[simple] WEB3524: Parse error in application web.xml
      org.xml.sax.SAXParseException: Element "web-app" does not allow "filter" here.
      at org.apache.crimson.parser.Parser2.error(Parser2.java:3160)

      The following is my web.xml file, thank you let me know what make it!

      <?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/j2ee/dtds/web-app_2_3.dtd">
      <web-app>
      <display-name>webapps-simple</display-name>
      <description>
      The jakarta-tomcat-4.0.3 sample apps ports over to Sun One Web Server.
      </description>
      <distributable></distributable>
      <servlet>
      <servlet-name>HelloWorldExample</servlet-name> <servlet-class>samples.webapps.simple.servlet.HelloWorldExample</servlet-class>
      </servlet>
      <servlet-mapping>
      <servlet-name>HelloWorldExample</servlet-name>
      <url-pattern>/helloworld</url-pattern>
      </servlet-mapping>
      <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      </welcome-file-list>
      <taglib> <taglib-uri>http://java.apache.org/tomcat/examples-taglib</taglib-uri> <taglib-location>/WEB-INF/tlds/example-taglib.tld</taglib-location>
      </taglib>
      <security-constraint>
      <web-resource-collection>
      <web-resource-name>Protected Area</web-resource-name>
      <url-pattern>/jsp/security/protected/*</url-pattern>
      <http-method>DELETE</http-method>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
      <http-method>PUT</http-method>
      </web-resource-collection>
      <auth-constraint>
      <role-name>tomcat</role-name>
      <role-name>role1</role-name>
      </auth-constraint>
      </security-constraint>
      <filter>
      <filter-name>Validation Filter</filter-name> <filter-class>filter.ISValidationFilter</filter-class>
      <init-param> <param-name>onlyAllowRequestWithToken</param-name>
      <param-value>true</param-value>
      </init-param>
      </filter>
      <filter-mapping>
      <filter-name>Validation Filter</filter-name>
      <url-pattern>/filtered/*</url-pattern>
      </filter-mapping>
      </web-app>
        • 1. Re: HELP: "web-app" does not allow "filter"
          807567
          As per the DTD, filter elements must appear before servlet elements.
          • 2. Re: HELP: "web-app" does not allow "filter"
            807567
            But I'm receiving the same error. web.xml is below:

            <?xml version="1.0" encoding="ISO-8859-1"?>
            <!DOCTYPE web-app
            PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
            "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
            <web-app>
            <display-name>WILMA</display-name>
            <context-param>
            <param-name>app_base</param-name>
            <param-value>/www/wilma/DEPLOY</param-value>
            </context-param>
            <filter>
            <filter-name>ChannelSecure</filter-name>
            <filter-class>com.xxx.objects.filter.ServletFilter</filter-class>
            </filter>
            <filter-mapping>
            <filter-name>ChannelSecure</filter-name>
            <url-pattern>/servlet/*</url-pattern>
            </filter-mapping>
            <session-config>
            <session-timeout>1800</session-timeout>
            </session-config>
            <taglib>
            <taglib-uri>wftags</taglib-uri>
            <taglib-location>/WEB-INF/xxx-taglib.tld</taglib-location>
            </taglib>
            </web-app>
            • 3. Re: HELP: "web-app" does not allow "filter"
              807567
              I'm having the same problem in Tomcat 5.0.27 except that the errors look like:
              SEVERE: Parse Error at line 15 column 11: Element type "filter" must be decl
              ared.
              org.xml.sax.SAXParseException: Element type "filter" must be declared.
              SEVERE: Parse Error at line 16 column 18: Element type "filter-name" must be
              declared.
              org.xml.sax.SAXParseException: Element type "filter-name" must be declared.
              SEVERE: Parse Error at line 17 column 19: Element type "filter-class" must b
              e declared.
              org.xml.sax.SAXParseException: Element type "filter-class" must be declared.
              SEVERE: Parse Error at line 48 column 19: Element type "filter-mapping" must be declared.
              org.xml.sax.SAXParseException: Element type "filter-mapping" must be declared.
              SEVERE: Parse Error at line 49 column 18: Element type "filter-name" must be
              declared.
              org.xml.sax.SAXParseException: Element type "filter-name" must be declared.
              SEVERE: Parse Error at line 162 column 11: The content of element type "web-
              app" must match "(icon?,display-name?,description?,distributable?,context-pa
              ram*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-li
              st?,error-page*,taglib*,resource-ref*,security-constraint*,login-config?,sec
              urity-role*,env-entry*,ejb-ref*)".


              i.e. It looks like <filter> isn't contatined in the DTD at all ????
              • 4. Re: HELP: "web-app" does not allow "filter"
                807567
                The <filter> web.xml element was introduced in Servlet 2.3. It's not possible to use <filter> in a web.xml deployment descriptor that refers to to the Servlet 2.2 DTD. Correct your web.xml DOCTYPE so it refers to the Servlet 2.3 DTD.
                • 5. Re: HELP: "web-app" does not allow "filter"
                  807567
                  I also getting the same error
                  my web.xml
                  <?xml version="1.0" encoding="ISO-8859-1"?>

                  <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

                  <web-app>

                       <filter>
                            <filter-name>Security Filter</filter-name>
                            <filter-class>org.securityfilter.filter.SecurityFilter</filter-class>
                            <init-param>
                                 <param-name>config</param-name>
                                 <param-value>/WEB-INF/securityfilter-config.xml</param-value>
                                 <description>Configuration file location (this is the default value)</description>
                            </init-param>
                            <init-param>
                                 <param-name>validate</param-name>
                                 <param-value>true</param-value>
                                 <description>Validate config file if set to true</description>
                            </init-param>
                       </filter>
                       <filter-mapping>
                            <filter-name>Security Filter</filter-name>
                            <url-pattern>/*</url-pattern>
                       </filter-mapping>
                  <!-- Action Servlet Configuration -->
                  <servlet>
                  <servlet-name>action</servlet-name>
                  <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
                  <init-param>
                  <param-name>config</param-name>
                  <param-value>/WEB-INF/struts-config.xml</param-value>
                  </init-param>
                  <init-param>
                  <param-name>debug</param-name>
                  <param-value>3</param-value>
                  </init-param>
                       <init-param>
                            <param-name>application</param-name>
                            <param-value>ApplicationResources</param-value>
                       </init-param>
                  <init-param>
                  <param-name>detail</param-name>
                  <param-value>3</param-value>
                  </init-param>
                  <load-on-startup>2</load-on-startup>
                  </servlet>
                  <!-- Action Servlet Mapping -->
                  <servlet-mapping>
                  <servlet-name>action</servlet-name>
                  <url-pattern>*.do</url-pattern>
                  </servlet-mapping>
                  <!-- The Welcome File List -->
                  <welcome-file-list>
                  <welcome-file>abc.jsp</welcome-file>
                  </welcome-file-list>
                  <taglib>
                  <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
                  <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
                  </taglib>

                  </web-app>

                  if I change as you said

                  <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
                  line with
                  <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

                  then it's not loading the application

                  pls suggest me
                  my mail id is jajain@cisco.com
                  • 6. Re: HELP: "web-app" does not allow "filter"
                    807567
                    What does "not loading the application" actually mean?

                    Did you check the errors log?
                    • 7. Re: HELP: "web-app" does not allow "filter"
                      807567
                      Thanks Evin
                      but I am getting the Error like


                      Element type "filter" must be declared.

                      Element type "filter-class" must be declared.

                      Element type "filter-name" must be declared.

                      could you tell me the reason, is I am mising any jar file or any other setting.
                      • 8. Re: HELP: "web-app" does not allow "filter"
                        807567
                        jayjain, let's start again.

                        What are you trying to do? What product are you using? What's going wrong? What ends up in the errors log? (Note that 'Element type "filter" must be declared.' does not look like a Sun Java System Web Server 6.1 errors log entry.)
                        • 9. Re: HELP: "web-app" does not allow "filter"
                          807567
                          Try using latest tomcat (atleast tomcat 4.1.31).