0

I would like to use the Spring Data Populator, but I am getting the SAXParseException:

Exception in thread "main"
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: 

Configuration problem: Failed to import bean definitions from URL location
[classpath*:spring-context/dbContext.xml]

Offending resource: class path resource [spring-context/applicationContext.xml];

nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 
Line 64 in XML document from URL [file:/home/pi/Workspace/AGServer/bin/spring-context/dbContext.xml] is invalid; 

nested exception is org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: 
Attribute 'location' is not allowed to appear in element 'repository:jackson-populator'.

My main server class is:

public final class ServerMain {

    private static final String APP_CONTEXT_XML = "spring-context/applicationContext.xml";

    public static void main(final String[] args) {
        final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(APP_CONTEXT_XML);
        context.registerShutdownHook();
    }
}

The applicationContext.xml loads other sub-files and looks like this:

<?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:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <import resource="classpath*:spring-context/serverContext.xml" />
    <import resource="classpath*:spring-context/dbContext.xml" />
    <import resource="classpath*:spring-context/jettyContext.xml" />
</beans>

And finally, the beginning of the dbContext.xml from where I invoke the Populator

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:repository="http://www.springframework.org/schema/data/repository"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    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-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.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">

    <!-- AUTH DS / PU / TX / SERVICE -->
    <!-- the repositories configuration, ommited for clarity -->

    <repository:jackson-populator location="classpath:auth.json" />

May that be caused somehow by conflicts with spring-beans-3.0.xsd? I saw in all (though not too many, e.g. here: http://docs.spring.io/spring-data/commons/docs/1.5.1.RELEASE/reference/htmlsingle/???#d0e893) documents that spring-beans.xsd, without any release id is used. I tried to change it, but that didn't help.

ppi
  • 86
  • 7
  • I cannot discover the namespace mapping for `repository` there seems to be no xsd attached. Also, as you already mention, it is recommended to use the versionless xsd files `spring-beans.xsd` etc. as that will always point to the version belonging to your spring version. – M. Deinum Jun 03 '14 at 10:17
  • thanks @m-deinum, indeed I forgot to include the two lines with the xsd - I am not familiar yet with Stackoverflow syntax and that causes me some problems. I edited the question. I also changed (in my code) the definitions to versionless - still getting exactly the same exception. – ppi Jun 03 '14 at 10:39
  • Are you using a Spring Data version that supports this? Which versions are you using. – M. Deinum Jun 03 '14 at 10:39
  • In this project we're using Ivy and I have: . In libraries I can see that Ivy pulled spring-data-jpa-1.3.2.RELEASE and spring-data-commons-1.5.1.RELEASE – ppi Jun 03 '14 at 10:44
  • 1
    I think it is a type. Should be `locations` instead of `location`, at least according to the xsd. – M. Deinum Jun 03 '14 at 11:07
  • @M. Deinum - thank you very much, indeed, that was the case. After pulling additional jackson-mapper-asl, it works! – ppi Jun 03 '14 at 11:29
  • Good catch! Yes the correct attribute to use is "locations". We just fixed the reference documentation :) – Thomas Darimont Jun 04 '14 at 09:38

0 Answers0