1

I'm trying to run my web application with some @Autowire on it so I have this context xml:

applicationContext.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: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">

    <context:annotation-config /> 
    <context:component-scan base-package="com.abc" />
</beans>

However I'm getting this error:

WARNING: Nested in org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 31; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.:
org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 31; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
quarks
  • 33,478
  • 73
  • 290
  • 513

1 Answers1

6

Remove trailing slash from URL in schemaLocation:

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">

It has to be consistent with the namespace declaration:

xmlns:context="http://www.springframework.org/schema/context"
Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
  • you wont let me increase my repo today, great eye :) +1 – mprabhat Apr 30 '12 at 08:53
  • I was just about to post it, beat me to it ;) – Bruce Lowe Apr 30 '12 at 08:54
  • Cool, this solved the issue with the context xml, however I still need to fix my real problem: http://stackoverflow.com/questions/10379887/reading-a-properties-file for actually "inject" a property value in a class – quarks Apr 30 '12 at 09:00