Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

spring

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 .... :(

like image 750
Ithar Avatar asked Oct 07 '13 11:10

Ithar


1 Answers

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.

like image 107
M. Deinum Avatar answered Sep 28 '22 18:09

M. Deinum