Ananth Duari
Ananth Duari

Reputation: 2889

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

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" />

Upvotes: 11

Views: 18946

Answers (8)

user626710
user626710

Reputation: 576

I had the same problem. Resolved this by adding schema definition for < repository > element even though I did not use it in persistence xml file: xsi:schemaLocation="http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository.xsd ..."

Upvotes: 0

043 sornalatha S
043 sornalatha S

Reputation: 1

by adding spring-data-commons will works for me

    implementation group: 'org.springframework.data', name: 'spring-data-commons', version: '2.4.4' //  spring-data-commons-2.4.4.jar

Upvotes: 0

jalogar
jalogar

Reputation: 1684

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.

Upvotes: 1

limitee
limitee

Reputation: 1

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!

Upvotes: 0

i42
i42

Reputation: 36

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...

Upvotes: 2

Abhiram
Abhiram

Reputation: 11

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

Upvotes: 1

dnc253
dnc253

Reputation: 40357

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

Upvotes: 1

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340953

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>

Upvotes: 1

Related Questions