Search code examples
springxsdspring-data

Error in spring application context schema


I have a maven-spring project in Eclipse and I have this annoying error message in one of my spring contexts:

Referenced file contains errors (jar:file:/M2_HOME/repository/org/springframework/spring-beans/3.1.2.RELEASE/spring-beans-3.1.2.RELEASE.jar!/org/springframework/beans/ factory/xml/spring-tool-3.1.xsd). For more information, right click on the message in the Problems View and select "Show Details..."

The show setails leads to this:

enter image description here

I using spring-data-jpa 1.2.0.RELEASE and the rest of my spring jars are 3.1.3.RELEASE. Regarding spring-data-commons-core - I don't even have a dependency to this jar in my pom but I can see it in my m2 repository along with spring-data-commons-parent and both of version 1.4.0.RELEASE, I don't know why (maybe those are part of spring-data-jpa?).

My application context schema:

<?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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
   http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd">

I don't understand why I keep getting this error. Basically it has no effect what so ever, The app compiles, deployed and runs just fine, it is just this annoying red error mark in Eclipse that drives me crazy :)


Solution

  • I have solved it by doing 3 things:

    1. Added this repository to my POM:

      <repository>
          <id>spring-milestone</id>
          <name>Spring Maven MILESTONE Repository</name>
          <url>http://repo.springsource.org/libs-milestone</url>
      </repository>
      
    2. I'm using this version of spring-jpa:

      <dependency>
          <groupId>org.springframework.data</groupId>
          <artifactId>spring-data-jpa</artifactId>
          <version>1.2.0.RELEASE</version>
      </dependency>
      
    3. I removed the xsd versions from my context (although I'm not sure it is necessary):

      <?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" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
        xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="
         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
         http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
         http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
      

    I hope this helps.