Announcement Announcement Module
Collapse
No announcement yet.
Failed to read 'http://www.springframework.org/schema/context/spring--context-3.0.xsd Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Failed to read 'http://www.springframework.org/schema/context/spring--context-3.0.xsd

    Hi,

    I was trying to use <context:component-scan> in my demo project and encounter an error.
    I have searched the solutions on the Internet, but can't get satisfied answer.

    The following two links are similar with my problems:
    [1]http://forum.springsource.org/showthread.php?77633-schema-document-http-www-springframework-org-schema-beans-spring-context-3-0-xsd

    [2]http://stackoverflow.com/questions/1729307/spring-schemalocation-fails-when-there-is-no-internet-connection

    The first one's error message is almost same with me, however the reason is he made a copy/paste mistake in configure file. I checked my file and there is no such problem.

    The second solution does solve my problem, but not perfectly. I will get correct result of my app when apply this
    solution, but it's a solution for offline mode(without Internet connection). Moreover, there is still error information saying "Failed to read schema document 'http://www.springframework.org/schema/tool/spring-tool-3.0.xsd'"

    My configure file is:
    Code:
    <?xml version = "1.0" encoding = "UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	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:component-scan base-package="com.springinaction.autodiscovery" />
    	
    </beans>
    When I replace the "spring-context-3.0.xsd" with "spring-context-2.5.xsd", everything is OK.
    Also, I can view the content of both "spring-context-3.0.xsd" and "spring-context-2.5.xsd" from the Eclipse.
    I want to know the reason of the problem and the strange phenomena.


    Thank you in advance~

    Here is the error I got:
    Code:
    org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/context/spring-context-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
            ....
    	at com.springinaction.autodiscovery.Demo.main(Demo.java:9)
    Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 14 in XML document from class path resource [autodiscovery.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:component-scan'.
    	...
    	at com.springinaction.autodiscovery.Demo.main(Demo.java:9)
    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:component-scan'.
    	...
    	... 14 more

  • #2
    Make sure that there aren't any conflicting jars (different spring versions) on the classpath. If you use spring 3.0 there should be no big fat spring.jar (which is spring 2.5 and before). Next if you are creating a uber jar which contains all packages als make sure you copy xsd files also.

    Comment


    • #3
      I'm sure there is no conflict jars in my project, all referenced jars on my build path are:
      antlr-runtime-3.0.jar
      commons-logging-1.0.4.jar
      org.springframework.asm-3.0.0.M3.jar
      org.springframework.beans-3.0.0.M3.jar
      org.springframework.context-3.0.0.M3.jar
      org.springframework.context.support-3.0.0.M3.jar
      org.springframework.core-3.0.0.M3.jar
      org.springframework.expression-3.0.0.M3.jar

      Also, my project is only a small demo app, it can be downloaded from the attachment.

      Comment


      • #4
        Well seems like the Spring in Action sample .

        Also why are you using an ancient milestone version of spring? I suggest at least upgrading to a final version (3.0.7 or 3.1.1)

        Comment


        • #5
          Thank you very much, Marten! I upgrade the spring jars to version 3.1.1 and it worked properly.
          My tiny app is indeed sample from the "Spring in Action", , I'm currently reading this book.

          Comment


          • #6
            Same problem with spring version 3.1.1.RELEASE

            Thanks for the solution. I had the same problem with version 3.1.1.RELEASE and had to rollback to 3.1.0.RELEASE. After the change no problem left.

            Comment

            Working...
            X