- This topic has 3 replies, 2 voices, and was last updated 19 years, 10 months ago by Riyad Kalla.
-
AuthorPosts
-
Erick DovaleMemberHello there folks,
I am having a problem with my web.xml that is kind of annoying although it does not prevents me from keep going.
The issue is as follow:
In my web.xml I have to add a taglib for spring.<?xml version="1.0" encoding="UTF-8"?> <web-app 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>movingplanner.ca "Ultimate moving tool"</description> <display-name>movingplanner.ca</display-name> <taglib> <taglib-uri>/spring</taglib-uri> <taglib-location>/WEB-INF/spring.tld</taglib-location> </taglib> <!-- Registering the session listener --> <listener> <listener-class> com.movingplanner.ui.MovingplannerSessionListener </listener-class> </listener> <servlet> <servlet-name>movingplanner</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>movingplanner</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/mockedBusinessBeans.xml /WEB-INF/movingplanner-servlet.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> </web-app>
Something is not well configured as eclipse shows an error in the taglib tag form the spring.tld
The description of the error is:
cvc-complex-type.2.4.a: Invalid content was found starting with element ‘taglib’. One of ‘{“http://java.sun.com/xml/ns/j2ee”:description, “http://java.sun.com/xml/ns/j2ee”:display-name, “http://java.sun.com/xml/ns/j2ee”:icon, “http://java.sun.com/xml/ns/j2ee”:distributable, “http://java.sun.com/xml/ns/j2ee”:context-param, “http://java.sun.com/xml/ns/j2ee”:filter, “http://java.sun.com/xml/ns/j2ee”:filter-mapping, “http://java.sun.com/xml/ns/j2ee”:listener, “http://java.sun.com/xml/ns/j2ee”:servlet, “http://java.sun.com/xml/ns/j2ee”:servlet-mapping, “http://java.sun.com/xml/ns/j2ee”:session-config, “http://java.sun.com/xml/ns/j2ee”:mime-mapping, “http://java.sun.com/xml/ns/j2ee”:welcome-file-list, “http://java.sun.com/xml/ns/j2ee”:error-page, “http://java.sun.com/xml/ns/j2ee”:jsp-config, “http://java.sun.com/xml/ns/j2ee”:security-constraint, “http://java.sun.com/xml/ns/j2ee”:login-config, “http://java.sun.com/xml/ns/j2ee”:security-role, “http://java.sun.com/xml/ns/j2ee”:env-entry, “http://java.sun.com/xml/ns/j2ee”:ejb-ref, “http://java.sun.com/xml/ns/j2ee”:ejb-local-ref, “http://java.sun.com/xml/ns/j2ee”:service-ref, “http://java.sun.com/xml/ns/j2ee”:resource-ref, “http://java.sun.com/xml/ns/j2ee”:resource-env-ref, “http://java.sun.com/xml/ns/j2ee”:message-destination-ref, “http://java.sun.com/xml/ns/j2ee”:message-destination, “http://java.sun.com/xml/ns/j2ee”:locale-encoding-mapping-list}’ is expected.Any hint??
thanks.
Erick
Riyad KallaMemberErick,
The problem has nothing to do with configuration, your web.xml file is invalid. That hellish error message you see is actually the XML parser saying “The XML Schema defines this file as having the following order, and your file doesn’t follow it!”You need to add a jsp-config section to your document, and put your taglib tags within it, if you look at the error above:
…<snip>
“http://java.sun.com/xml/ns/j2ee”:error-page, “http://java.sun.com/xml/ns/j2ee”:jsp-config, “http://java.sun.com/xml/ns/j2ee”:security-constraint,
…<snip>You can see the “jsp-config” section should come down towards the end of the file, looking at your file I’d say it will be at the end. So you would need to add this:
<jsp-config> <taglib> <taglib-uri>/spring</taglib-uri> <taglib-location>/WEB-INF/spring.tld</taglib-location> </taglib> </jsp-config>
Erick DovaleMemberthat did the trick rkalla..
thanks a lot.
Now, why is it that it was perfectly working?cheers,
Erick.
Riyad KallaMemberNow, why is it that it was perfectly working?
It likely worked until you added the taglib reference, but after adding it made the file invalid. I doubt it worked after the file was marked invalid, it might have just been a reloading issue with Tomcat still using the old web.xml. I suppose (technically speaking) if Tomcat uses Commons Digester AND turned off validation then it still might work as it would just skip over the taglib section, but I’ve never seen a web context with an invalid description load… in any app server.
-
AuthorPosts