6

I am using Spring 3.2.3.RELEASE with maven to pull the dependencies. When building the project in Eclipse am getting following error:

Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 17 in XML document from class path resource [META-INF/spring/application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 64; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.

My appication-context.xml has the following:

<?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.2.xsd
    http://www.springframework.org/schema/context/
  http://www.springframework.org/schema/context/spring-context-3.2.xsd">

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

I know that I am pulling the correct jar files as my Maven Dependencies shows:

Eclipse Maven Dependencies

Inside the META-INF/sping.schemas I can see that I have the right schema declaration in my jar:

http\://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd
http\://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd
http\://www.springframework.org/schema/context/spring-context-3.1.xsd=org/springframework/context/config/spring-context-3.1.xsd
http\://www.springframework.org/schema/context/spring-context-3.2.xsd=org/springframework/context/config/spring-context-3.2.xsd
http\://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.2.xsd

I have also looked at these to no avail:

Can't load spring 3 schemas

The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'

No declaration can be found for element 'context:component-scan'

The matching wildcard is strict, but no declaration can be found for element 'context:component-scan

Please help, it's driving me crazy .... :(

Community
  • 1
  • 1
Ithar
  • 4,865
  • 4
  • 39
  • 40

1 Answers1

14

For starters you should fix your dependencies. You are mixing Spring 3.2.3 and 2.0.6 jars (that is problems waiting to happen).

Next to that your declaration is wrong http://www.springframework.org/schema/context/ must be http://www.springframework.org/schema/context.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224