Tuesday, January 24, 2017

applicationContext.xml validation errors on Eclipse

We know that everything is correct with respect your schema definitions and bean definitions in your applicationContext.xml. These errors are particularly seen when we declare "jpa:repositories" to look for Spring Data JPA repository interfaces as shown below.


<jpa:repositories base-package="com.swappow.web.data.repository" query-lookup-strategy="create-if-not-found"/>

Following are the error messages that you will notice.

Referenced file contains errors (http://www.springframework.org/schema/context/spring-context-4.3.xsd). For more information, right click on the message in the Problems View and select "Show Details..."

The errors below were detected when validating the file "spring-context-4.3.xsd" via the file "applicationContext.xml".  In most cases these errors can be detected by validating "spring-context-4.3.xsd" directly.  However it is possible that errors will only occur when spring-context-4.3.xsd is validated in the context of applicationContext.xml.

sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.sprinkframework.org/schema/context, propertyLoading'

In order to resolve these validation errors, we will have to remove "jpa:repositories" definition or add the following lines to your XML.


<context:annotation-config /> 
<context:component-scan base-package="com.example.app"/>

Note: This issue is observed with Spring Framework 4.3.5 schema definition, Spring JPA 1.8 definition, and Eclipse version: Neon.2 Release (4.6.2)