Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7165173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:11:48+00:00 2026-05-28T14:11:48+00:00

I have a dispatcher-servlet.xml and an applicationContext.xml. I have been doing some refactoring, and

  • 0

I have a dispatcher-servlet.xml and an applicationContext.xml.

I have been doing some refactoring, and moved

<mvc:annotation-driven/>
<context:component-scan base-package="com.xxx"/>

from dispatcher-servlet.xml to applicationContext.xml.

I now get this error:

2012-01-26 10:34:36.434:WARN::Nested in org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/applicationContext.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 'context:component-scan'.:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.

My applicationContext.xml looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.2.xsd"
       xmlns:context="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
        >

    <mvc:annotation-driven/>
    <context:component-scan base-package="com.xxx"/>

    <bean id="templateErrorListener"
          class="com.stringtemplate.log.Slf4jStringTemplateErrorListener"/>

    <bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
          p:config-location="/WEB-INF/ehcache.xml"/>

    <ehcache:annotation-driven cache-manager="ehCacheManager"/>

</beans>

and my dispatcher-servlet.xml looks like:

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

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <property name="order" value="1"/>
        <property name="mediaTypes">
            <map>
                <entry key="json" value="application/json"/>
            </map>
        </property>
        <property name="defaultViews">
            <list>
                <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"/>
            </list>
        </property>
        <property name="ignoreAcceptHeader" value="true"/>
    </bean>

    <bean class="com.stringtemplate.StringTemplateViewResolver">
        <property name="templateErrorListener" ref="templateErrorListener"/>
        <property name="templateRoot" value="/WEB-INF/templates/"/>
        <property name="order" value="2"/>
    </bean>
    <!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="order" value="3"/>
        <property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="messageConverters">
            <list>
                <ref bean="formHttpMessageConverter"/>
                <ref bean="stringHttpMessageConverter"/>
            </list>
        </property>
    </bean>

    <bean id="formHttpMessageConverter "
          class="org.springframework.http.converter.FormHttpMessageConverter "/>
    <bean id="stringHttpMessageConverter "
          class="org.springframework.http.converter.StringHttpMessageConverter "/>

    <bean id="restTemplate" class="org.springframework.web.client.RestTemplate"/>

    <bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:${systemTargetEnv}/app.properties</value>
                <value>classpath:/build.properties</value>
            </list>
        </property>
        <property name="systemPropertiesModeName">
            <value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
        </property>
    </bean>
</beans>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:11:49+00:00Added an answer on May 28, 2026 at 2:11 pm

    I have been doing some refactoring, and moved <mvc:annotation-driven/> from dispatcher-servlet.xml to applicationContext.xml.

    You don’t want to do that. <mvc:annotation-driven/> is there to enable annotation-style MVC controllers, and those controllers must reside in dispatcher-servlet.xml. Putting <mvc:annotation-driven/> in applicationContext.xml is pointless, it will have no meaningful effect.

    I should probably answer the question, though, amnd the answer is that while you’ve declared the mvc namespace, you did not tell Spring where to find the schema for it. Add

    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
    

    to the schemaLocation attribute in applicationContext.xml

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webapp in which I define the basic dispatcher-servlet context in web.xml
I have a pretty simple JSP/Servlet 3.0/Spring MVC 3.1 application. On one of my
I have a Struts2 (2.1.8.1) web application. My web.xml looks like, <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
I have standard servlet-mapping for Dispatcher Servlet - /app/* . I have controller that
The scenario: Some common beans are defined in context xml files. DispatcherServlet is mapped
i have written a small webapp using spring-security and spring-mvc with an annotation based
I have a spring mvc project set up like so: <servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param>
I have an HTTP Request Dispatcher class that works most of the time, but
I have written a simple Java dispatcher with a daemon thread to handle the
I have the view function in django that written like a dispatcher calling other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.