0

I tried everything I can think of, but nothing seems to work.

I am using the current version of Spring Framework (3.2) in my java web application. Every time I start my project I get the following error:

cvc-elt.1: Cannot find the declaration of element 'beans'

this is my 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"
     xsi:schemaLocation="http://www.springframework.org/schema/beans      
               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"

</beans>

I tried to :

  1. change the version of the schema (3.2, 2.0...)
  2. copy the schema from the jar into WEB-INF
  3. change unix EOL into windows EOL

and nothing seems to work, except using the DTD declaretion instead of the XSD. What should I do?

hdmi3killer
  • 89
  • 1
  • 1
  • 12

2 Answers2

0

The xsd came down fine for me when I pasted it in the browser.

This one works fine for me:

<?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="example"/>

</beans>
duffymo
  • 305,152
  • 44
  • 369
  • 561
0

Spring is having trouble finding the xsds. Take a look at this SO post. If you are sure you have the required spring-beans jar in your classpath, you may have a corrupted META-INF/spring.schemas file. The spring.schemas file tells spring which classpath to use to find the corresponding xsd file in the spring jars. I have had this occur when using the maven-shade plugin improperly configured.

Community
  • 1
  • 1
Eric B.
  • 23,425
  • 50
  • 169
  • 316