Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in spring application context schema

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:file:/M2_HOME/repository/org/springframework/spring-beans/3.1.2.RELEASE/spring-beans-3.1.2.RELEASE.jar!/org/springframework/beans/ factory/xml/spring-tool-3.1.xsd). For more information, right click on the message in the Problems View and select "Show Details..."

The show setails leads to this:

enter image description here

I using spring-data-jpa 1.2.0.RELEASE and the rest of my spring jars are 3.1.3.RELEASE. Regarding spring-data-commons-core - I don't even have a dependency to this jar in my pom but I can see it in my m2 repository along with spring-data-commons-parent and both of version 1.4.0.RELEASE, I don't know why (maybe those are part of spring-data-jpa?).

My application context schema:

<?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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    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.1.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
   http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd">

I don't understand why I keep getting this error. Basically it has no effect what so ever, The app compiles, deployed and runs just fine, it is just this annoying red error mark in Eclipse that drives me crazy :)

like image 537
forhas Avatar asked Dec 03 '12 22:12

forhas


People also ask

What is the application context in Spring?

ApplicationContext is a corner stone of a Spring Boot application. It represents the Spring IoC container and is responsible for instantiating, configuring, and assembling the beans. The container gets its instructions on what objects to instantiate, configure, and assemble by reading configuration metadata.

Can we have multiple application context in Spring?

We can have multiple application contexts that share a parent-child relationship. A context hierarchy allows multiple child contexts to share beans which reside in the parent context. Each child context can override configuration inherited from the parent context.

What is application context xml in Spring?

Applicationcontext. xml - It is standard spring context file which contains all beans and the configuration that are common among all the servlets. It is optional file in case of web app. Spring uses ContextLoaderListener to load this file in case of web application. Spring-servlet.


1 Answers

I recently had a similar problem in latest Eclipse (Kepler) and fixed it by disabling the option "Honour all XML schema locations" in Preferences > XML > XML Files > Validation. It disables validation for references to the same namespaces that point to different schema locations, only taking the first found generally in the XML file being validated. This option comes from the Xerces library.

WTP Doc: http://www.eclipse.org/webtools/releases/3.1.0/newandnoteworthy/sourceediting.php

Xerces Doc: http://xerces.apache.org/xerces2-j/features.html#honour-all-schemaLocations

like image 90
Ulises Avatar answered Sep 17 '22 18:09

Ulises