TKV
TKV

Reputation: 2663

Configuration problem:Spring NamespaceHandler for [http://www.springframework.org/schema/mvc]

Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/mvc].

can anyone tell why this error is happening? this is my configuration.

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

Upvotes: 8

Views: 21904

Answers (5)

RamBen
RamBen

Reputation: 1020

due to lack of spring-webmvc dependency It will happen so add the spring-webmvc dependency to pom.xml (or add the jars if not using maven or any build

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>

Upvotes: 0

Tejas Ghonge
Tejas Ghonge

Reputation: 65

I was getting same error while development on Eclipse. Some time it happens that required JAR is there at the correct location, but still this error message doesn't disappear. Don't Panic. First check if any of the above answers are working for you. If its not working follow below steps if you are facing this while development on Eclipse/STS.

  1. Clean your Local Server (Tomcat in my case).
  2. Remove project resource from server and Republish it.
  3. Clean Build your project again and see the result.

Issue resolved in my case.

Upvotes: 0

fredde
fredde

Reputation: 62

Have you had a look at this?

maven shade plugin or this maven shade plugin 2

It solved my problem with finding the spring context xml's.a link

Upvotes: 0

m2p
m2p

Reputation: 81

@Tijo

You need to check few things:

  1. Whether the Spring version you are using is 3.0. You are referring to spring-beans-3.0.xsd, spring-context-3.0.xsd and spring-mvc-3.0.xsd in your configuration, so you need to use Spring 3.0.* JARs.

  2. You may already have all the required JARs in the build path, most likely as "Referenced libraries" by adding external JARs to your build path. You also need to keep all the JARs in the webapp's WEB_INF/lib/ folder (put them in that folder directly, and not in a sub-folder of WEB-INF/lib/). Only then your web server knows about them. This is what Bozho means.

  3. This is more subtle. Make sure you do not have multiple Spring JAR versions in your WEB-INF/lib folder.

These are the same steps one needs to check for other NameSpaceHandler errors too, like

Unable to locate Spring NamespaceHandler for XML schema namespace
http://www.springframework.org/schema/context

or

Unable to locate Spring NamespaceHandler for XML schema namespace
[http://www.springframework.org/schema/security]

Hope that helps!

Upvotes: 8

Bozho
Bozho

Reputation: 597124

Spring needs a NamespaceHandler on the (runtime) classpath that can handle the mvc: namespace. This is the MvcNamespaceHandler, and it is located in the spring-webmvc-xx.jar. Put that on your classpath.

Upvotes: 3

Related Questions