Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring data xml configuration schema validation error

I have a project using Spring (context, transaction, apect) 4.1.6.RELEASE and spring-data-jpa 1.8.0.RELEASE and encountering strange errors, assumingly caused by xsd validation. However, I cannot figrue out the cause. Strangely, the projects runs fine, all my beans are correctly recognized.

I'm using Eclipse luna and Spring Tools Suite plugin

I removed everything from my applicationContext.xml except the "jpa:" line which causes problems. The xml has been created with the STS plugin.

I tried to remove version numbers from the xsds, without success.

enter image description here

like image 753
Raphael Roth Avatar asked Sep 27 '22 08:09

Raphael Roth


2 Answers

I faced the same problem some time ago, all errors were caused by jpa thing i moved the jpa configuration to a new configuration file

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    default-destroy-method="destroy"
    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-4.1.xsd
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd">

    <context:component-scan base-package="com.some.validator" />
    <context:component-scan base-package="com.some.security.rest" />
    <jpa:repositories base-package="com.some.repository.path"
        entity-manager-factory-ref="entityManagerFactory" />
</beans>

some maven imports:

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.8.2.RELEASE</version>
    </dependency>

and spring framework version

    <org.springframework-version>4.1.7.RELEASE</org.springframework-version>

Try to clean project and update it with maven

like image 165
Oskar Dajnowicz Avatar answered Sep 29 '22 00:09

Oskar Dajnowicz


I had the same problem than you and it came from the versions of the xsd files. In particular, the issue went away when I remove the spring Context XSD version.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
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.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/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">

<jpa:repositories base-package="com.app.repositories" />
</beans>

That XML file does not generate any validation error for me.

Cheers,

Emmanuel

like image 29
Emmanuel Avatar answered Sep 29 '22 01:09

Emmanuel