Java – Problem while Upgrading web.xml to 2.4 from 2.3

javaservletsweblogic

I am trying to upgrade my web.xml from 2.3 to 2.4, so I changed my web.xml to something like this –

<?xml version="1.0" encoding="UTF-8"?>
<!--<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1
Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">-->

<!--
    ===========================================================
                           WUI - WEB.XML
    ===========================================================
--> 

<web-app id="WebApp" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/
    ns/j2ee/web-app_2_4.xsd"
    version="2.4">

    <description>Odyssey Web User Interface</description>
    <display-name>wui</display-name>



<!-- Uncomment this when setting up the prevent-multiple-login mechanism -->
<!--
    <listener>
        <listener-class>com.xxx.xxxnListener</listener-class>
    </listener>
-->

    <!--  local cache filter setup -->
    <filter> 
      <filter-name>local-cache</filter-name> 
      <filter-class>com.xxx.xxxcheFilter</filter-class> 
   </filter> 
....

When I start my Server, I get this error –

weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
problem: cvc-complex-type.2.4a: Expected elements 'servlet-class@http://java.sun.com/xml/ns/javaee jsp-file@http://java.sun.com/xml/ns/javaee' instead of 'display-name@http://java.sun.com/xml/ns/javaee' here in element servlet@http://java.sun.com/xml/ns/javaee:
problem: cvc-complex-type.2.4a: Expected elements 'servlet-class@http://java.sun.com/xml/ns/javaee jsp-file@http://java.sun.com/xml/ns/javaee' instead of 'description@http://java.sun.com/xml/ns/javaee' here in element servlet@http://java.sun.com/xml/ns/javaee:

I am using weblogic 10.1 server.

Any idea what else am I supposed to do.

Thanks.

Best Answer

The structure of your web.xml needs to change to pass the new XSD. For example the new XSD states that your web.xml file should have:

<servlet-class> or <jsp-file> as an element in the place where you currently have <display-name>

Read the XSD at http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd for more details, it shouldn't take long to restructure so that it passes.