1

I meet an exception running a project using spring data jpa


org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 18 in XML document from class path resource [META-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/spring-jpa.xsd; lineNumber: 18; columnNumber: 51; src-resolve: Cannot resolve the name 'repository:repositories' to a(n) 'type definition' component.

I read through many docs and blogs and I think this is possibly caused by incompatibility of spring data jpa and spring data commons package versions.

Now I'm using

  • spring-data-commons-core-1.4.1.Release
  • spring-data-commons-1.10.0.release
  • spring-data-jpa-1.8.0.

Any suggestion on the version control to get rid of such error?

Also I would like to ask for suggestions how to make such version control easier(any website, docs or tools). Thanks for advice in advance.

Below is the namespace I use

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

The repository:repository is not from my applicationContext.xml. I did use jpa:repository as

<jpa:repositories base-package="com.canreef.calendar"/>
M. Deinum
  • 115,695
  • 22
  • 220
  • 224
OrlandoL
  • 898
  • 2
  • 12
  • 32
  • `repository:repositories` should be `jpa:repositories`... For managing your dependencies use something like maven or gradle don't go searching for yourself. – M. Deinum May 28 '15 at 10:02
  • I did use the jpa:repository – OrlandoL May 29 '15 at 08:47
  • @Deinum I did use jpa:repository, that repository:repository must come from an xml. I've added to the post, pls check. – OrlandoL May 29 '15 at 08:57
  • As mentioned don't search for dependencies yourself, use maven to do that for you... Saves you a lot of headaches. Remove the `spring-data-commons-core` jar as that is old, really old... Also why do you need that `spring-repository.xsd` in your declaration? If you aren't using it just remove it. – M. Deinum May 29 '15 at 09:01
  • @Deinum Thanks for your suggestion but removing the repository.xsd dependency unfortunately didn't help. I removed the entries related to repository in namespace, but the exception is the same. – OrlandoL May 29 '15 at 09:27
  • As stated remove the old dependency as that is from 2013 and not relevant anymore. I also suggested that you should use something like maven to manage your dependencies instead of trying to find workable combinations yourself. – M. Deinum May 29 '15 at 09:43
  • Yes I am using maven to manage the dependency and now I'm pretty sure there is no trouble with the dependencies. I just found this problem roots in the spring-repository.xsd – OrlandoL May 29 '15 at 10:03
  • No it isn't... You have an old dependency... Which you shouldn't use remove that dependency... You should only have spring-data-jpa and spring-data-commons nothing more for spring-data. – M. Deinum May 29 '15 at 10:28

1 Answers1

0

I found this roots in spring-repository.xsd In spring-jpa.xsd there is a line with ref to repository:auditing-attributes:

<xsd:element name="auditing">
        <xsd:annotation>
            <xsd:appinfo>
                <tool:annotation>
                    <tool:exports type="org.springframework.data.jpa.domain.support.AuditingEntityListener" />
                    <tool:exports type="org.springframework.data.auditing.AuditingHandler" />
                </tool:annotation>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:attributeGroup ref="repository:auditing-attributes" />
        </xsd:complexType>
    </xsd:element>

While in spring-repository.xsd there is the bean:

-<xsd:attributeGroup name="auditing-attributes">


-<xsd:attribute name="auditor-aware-ref">


-<xsd:annotation>


-<xsd:documentation>

<![CDATA[ References a bean of type AuditorAware to represent the current principal. ]]>

</xsd:documentation>


-<xsd:appinfo>


-<tool:annotation kind="ref">

<tool:assignable-to type="org.springframework.data.domain.AuditorAware"/>

</tool:annotation>

</xsd:appinfo>

</xsd:annotation>

</xsd:attribute>


...omitted...

</xsd:attributeGroup>

Therefore this should be caused by not able to fetch the repository.xsd.

OrlandoL
  • 898
  • 2
  • 12
  • 32
  • Does any have any ideas where this spring-repository.xsd resides? I can't find it in any jar. – OrlandoL May 29 '15 at 10:01
  • Since this seems to be another problem I simply started another thread http://stackoverflow.com/questions/30542876/cannot-resolve-the-name-repositoryrepositories-to-an-type-definition-comp – OrlandoL May 30 '15 at 06:02