Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring 3.0 -- Unable to locate Spring NamespaceHandler for XML schema namespace context

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

SEVERE: Exception sending context initialized event to listener instance of
class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate NamespaceHandler for namespace
[http://www.springframework.org/schema/context]
Offending resource: ServletContext resource [/WEB-INF/HelloWorld-service.xml]

This is my HelloWorld-service.xml:

<?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:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
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/util
    http://www.springframework.org/schema/util/spring-util-3.0.xsd"
     default-autowire="byName">

<context:component-scan base-package="com.test.service">
    <context:include-filter type="annotation"
        expression="org.springframework.stereotype.Service"/>
</context:component-scan>   

In my pom.xml I have:

<properties>
    <spring.version>3.0.5.RELEASE</spring.version>
</properties>
........
<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${spring.version}</version>
    </dependency>

Project tree structure:
enter image description here Any ideas what could be the cause of this?

like image 287
Kiran Avatar asked Apr 05 '15 10:04

Kiran


2 Answers

Ususally this happens when I started the WebApp under eclipse; I don't know why, it seems Eclipse can't find spring jars containing the spring XSD schemas Usually I solved it by adding spring jars under WEB-INF/lib directory (by using the same identical name declared in the pom.xml)

like image 155
Angelo Immediata Avatar answered Nov 07 '22 05:11

Angelo Immediata


If you are working with eclipse then try following steps:

Right click on project->properties->Deployment Assembly->Java build path entries-> Maven dependencies

That means add maven dependencies in your deployment assembly

like image 31
Nimesh Avatar answered Nov 07 '22 05:11

Nimesh