I have a maven-spring project in Eclipse and I have this annoying error message in one of my spring contexts:
Referenced file contains errors (jar:fil
I recently had same issue with Spring 4.0.
It was caused by a collision in names from spring-beans-4.0.xsd
and spring-context-4.0.xsd
.
Opening spring-context-4.0.xsd
you can see that spring-beans-4.0.xsd
is imported like follow:
<xsd:import namespace="http://www.springframework.org/schema/beans"
schemaLocation="http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"/>
These name's collisions make Eclipse complain about "...A schema cannot contain two global components with the same name..."
A noteworthy aspect is that I hadn't this problem with Eclipse Kepler SR2 but Eclipse Luna SR1, comparing both preferences about XML Validation, they were the same.
It was solved by removing spring-context-4.0.xsd from xsi:schemaLocation attribute:
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
After this everything worked as expected.
What @forhas and @HRgiger did also worked for me. I am using spring-data-mongodb
instead of jpa
.
However, for mongodb bindings, you should not remove the version of mongodb reference xsd, just keep it with version: http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
. context
and beans
versions should be removed.
I also faced this problem and fixed it by removing version part from the XSD name.
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd to http://www.springframework.org/schema/beans/spring-beans.xsd
Versions less XSD's are mapped to the current version of the framework used in the application.
Steps to resolve this issue 1.Right click on your project 2.Click on validate option
Result :TODO issue resolved
I have recently had same issue with JPA-1.3
Nothing worked until I used explicit tools.xsd link
xsi:schemaLocation=" ...
http://www.springframework.org/schema/tool
http://www.springframework.org/schema/tool/spring-tool-3.2.xsd
... ">
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:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
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.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/tool
http://www.springframework.org/schema/tool/spring-tool-3.2.xsd
">
What I did with spring-data-jpa-1.3 was adding a version to xsd and lowered it to 1.2. Then the error message disappears. Like this
<beans
xmlns="http://www.springframework.org/schema/beans"
...
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-1.2.xsd">
Seems like it was fixed for for 1.2 but then appears again in 1.3.