Java – The matching wildcard is strict, but no declaration can be found for element ‘resources’

By | October 22, 2023

I know this is a duplicate and you people are gonna chide me for it, but I didn’t get a proper solution after reading all the posts.
I am trying to build a Spring Template application in Spring Source Tool Suite.
I am getting the following error.

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 16 in XML document from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘resources’.

My root-context.xml is like this:

<?xml version="1.0" encoding="UTF-8"?>

    <!-- Root Context: defines shared resources visible to all other web components -->


Please let me know if there is a jar file missing in my application.
These are the only jar files I have in my application:
displaytag-1.0-b3.jar, spring-2.0.6.jar, spring-asm-3.0.3.RELEASE.jar, spring-beans-3.0.3.RELEASE.jar, spring-context-3.0.3.RELEASE.jar, spring-core-3.0.3.RELEASE.jar, spring-expression-3.0.3.RELEASE.jar, spring-hibernate3-2.0.8.jar, spring-web-3.0.3.RELEASE.jar & spring-webmvc-3.0.3.RELEASE.jar

Here is my servlet-context.xml

<?xml version="1.0" encoding="UTF-8"?>

    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="/resources/" />

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />

    <context:component-scan base-package="" />


Please help…it’s really annoying.

Best Solution

Your XML is fine, but according to this comment on a SpringSource blog post about Spring MVC 3

The <mvc:resources/> tag is a new feature coming in Spring Framework 3.0.4

Your application uses Spring 3.0.3, so you need to upgrade to 3.0.4 or later to be able to use the resources tag.

Category: Uncategorized