Cannot resolve the name 'repository:repository' to a(n) 'type definition' component.
Asked Answered
C

6

10

I am getting this error while trying to integrate Spring Data. The full stack trace is

nested exception is org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/spring-jpa.xsd; lineNumber: 18; columnNumber: 48; src-resolve: Cannot resolve the name 'repository:repository' to a(n) 'type definition' component.
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)

The XML file is

<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://www.springframework.org/schema/data/jpa"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/data/jpa
        http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
    <repositories base-package="com.interviewedonline.poc.repositories" />

Coelenteron answered 23/9, 2012 at 8:0 Comment(1)
Did you find solution for this ?Patsypatt
M
2

I had the same problem with the XSD file.

I've changed my Spring data Data Commons 1.4 to Spring Data Commons 1.3.2 and everything works perfectly fine now...

Morpheus answered 5/2, 2013 at 13:53 Comment(0)
S
1

You need to define Spring Data JPA XML namespace first:

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

    <jpa:repositories base-package="com.interviewedonline.poc.repositories" />

</beans>

Or if you want to use default XML namespace as in your example:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/data/jpa"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:beans="http://www.springframework.org/schema/beans"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/data/jpa
        http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">

    <repositories base-package="com.interviewedonline.poc.repositories" />

</beans:beans>
Sink answered 23/9, 2012 at 8:3 Comment(5)
No luck. I have tried both the options. Still getting the same exception. Not sure is there any jar conflict. I am using 3.1.2 version of spring.Coelenteron
@AnanthDuari: Do you have spring-data-jpa*.jar on your CLASSPATH? spring*.jar is not enough.Sink
yes, I have spring-data-jpa-1.1.0.RELEASE.jar, spring-data-rest-core-1.0.0.RC3.jar, spring-data-rest-repository-1.0.0.RC3.jar and spring-data-rest-webmvc-1.0.0.RC3.jar. Still getting the error.Coelenteron
have tried with different versions of XSD. Still the same problem. Even though I can see repository:repository there. Tried with springframework.org/schema/data/jpa/spring-jpa-1.0.xsdCoelenteron
I am getting exactly the same issue #13246606Alderson
C
1

I had the same error. Adding spring-data-commons-core seemed to fix it for me.

Coracoid answered 2/10, 2012 at 5:11 Comment(4)
Could you please share your spring(and spring-data spring-data-solr) version?Alderson
I'm using spring 3.1.1, spring-data-jpa-1.1.0, and spring-data-commons-core-1.3.0.Coracoid
After changing the version of spring-data-commons-core from 1.4.0 to 1.3.0, I got java.lang.ClassNotFoundException: org.springframework.data.repository.config.RepositoryConfigurationExtensionAlderson
@Alderson have you found a solution yet?Lawanda
H
1

I added this jar spring-data-commons-core-1.2.1.RELEASE

In Pom.xml added the below entry

<dependency>
     <groupId>org.springframework.data</groupId>
     <artifactId>spring-data-commons-core</artifactId>
     <version>1.2.1.RELEASE</version>
</dependency>

In the jpa configurator file added the below entry under xsi:schemaLocation http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd

Haunted answered 29/1, 2013 at 3:29 Comment(0)
P
1

I recently had this error updating the dependencies of an old project. The problem I had was that this dependency:

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-commons-core</artifactId>
  <version>1.5.1.RELEASE</version>
</dependency>

has been renamed and now the correct one is

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-commons</artifactId>
  <version>1.8.1.RELEASE</version>
</dependency>

As I had declared spring-data-commons-core and spring-data-commons was a transitive dependency of data-mongodb, I ended up with both jars and the classloader was using spring-data-commons-core that is incorrect.

Pleiades answered 9/7, 2014 at 8:50 Comment(0)
C
0

In some Spring .jar files,you can find META-INF folder.You'll find spring.handlers and spring.schemas in that folder. spring-data-commons-.jar do have. If you use Maven, you should create META-INF folder under src/main/resources and append the content of spring.handlers,spring.schemas in the spring-data-commons-.jar to your spring.handlers,spring.schemas.

Have a good luck!

Comer answered 17/9, 2013 at 7:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.