Announcement Announcement Module
Collapse
No announcement yet.
Spring 3 Annotations <context:annotation-config /> Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3 Annotations <context:annotation-config />

    Using Spring 3 (spring-framework-3.0.0.M3).
    org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
    Q: Are the Spring 3 schema definitions legitimate?


    I would like to use annotations but getting the following whenever I add <context:annotation-config /> to the spring configuration file (simple.xml)
    Code:
    2009-06-10 16:08:30,013 INFO [org.springframework.context.support.ClassPathXmlApplicationContext] - <Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@ba4211: display name [org.springframework.context.support.ClassPathXmlApplicationContext@ba4211]; startup date [Wed Jun 10 16:08:30 MST 2009]; root of context hierarchy>
    2009-06-10 16:08:30,061 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Loading XML bean definitions from class path resource [com/jgk/spring3/simple/annotations/simple-annotated.xml]>
    2009-06-10 16:08:30,081 DEBUG [org.springframework.beans.factory.xml.DefaultDocumentLoader] - <Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]>
    2009-06-10 16:08:30,117 DEBUG [org.springframework.beans.factory.xml.PluggableSchemaResolver] - <Loading schema mappings from [META-INF/spring.schemas]>
    2009-06-10 16:08:30,123 DEBUG [org.springframework.beans.factory.xml.PluggableSchemaResolver] - <Loaded schema mappings: {http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, 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.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.5.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd}>
    2009-06-10 16:08:30,126 DEBUG [org.springframework.beans.factory.xml.PluggableSchemaResolver] - <Found XML schema [http://www.springframework.org/schema/beans/spring-beans-3.0.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-3.0.xsd>
    Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 15 in XML document from class path resource [com/jgk/spring3/simple/annotations/simple-annotated.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:378)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:316)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:284)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
    	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:114)
    	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:81)
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:126)
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:419)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:349)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
    	at com.jgk.spring3.simple.annotations.CheckSpringAnnotatedApp.main(CheckSpringAnnotatedApp.java:12)
    Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:429)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3185)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1955)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:725)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
    	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)
    	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
    	at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:370)
    	... 14 more
    Spring Configuration File (simple-annotated.xml):


    Code:
    <?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">
    
    	<bean id="simpleAnnotatedPojo"
    		class="com.jgk.spring3.simple.annotations.SimpleSpringAnnotatedPojo">
    	</bean>
    
    	<!-- more bean definitions go here -->
    	<context:annotation-config />
    
    </beans>

  • #2
    I get same error, but with <context:component-scan base-package="spa" />
    Namespace point to spring 3.0. When point to 2.5 i don't get that error. Instead, i get an error when i use "authentication-provider" tag.
    Can someone to help with that?

    Comment


    • #3
      vlad2005,

      I also ended up going back to the 2.5. The documentation implies there is a 3.0 version of the xsd.

      So not sure if it's something coming soon? Or if the documentation should be changed to show 2.5.

      Comment


      • #4
        I resolved. Thanks!

        Comment


        • #5
          Spring 3 and 3.0 xsd mystery

          vlad2005

          Did you resolve the 3.0 xsd? (or are you using the 2.5 xsd?)

          If you did resolve the 3.0 xsd what was the resolution?

          Thank you

          Comment


          • #6
            I resolved, but because i'm an beginner on spring, i don't understand very well all. So now, i have an separate file to configure security, and another for applicationContext.
            Anyway, after i fix all erors, i see that don't work with 3.0, only with 2.5. Probably this will be fix soon.

            Comment


            • #7
              Where is the Schema?

              I am getting the same exception. The Schema location in the docs is:

              http://www.springframework.org/schem...ontext-3.0.xsd

              But if I try to retrieve it in a browser I get redirected to:

              http://www.springsource.org/

              Can someone sort this out please?

              btw - really loving Spring 3 in general so far... cheers!

              Comment


              • #8
                Originally posted by javapda View Post
                Using Spring 3 (spring-framework-3.0.0.M3).
                org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
                Q: Are the Spring 3 schema definitions legitimate?

                ...
                You used incorrect schema for the 'context' namespace. I checked spring3M3 schema configuration and see that it points to the 2.5 version. I.e. you should use

                HTML Code:
                <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-2.5">

                Comment

                Working...
                X