What is the cause to get Multiple annotations found in dispatcher servlet - spring

I am working on spring 4.0. I have configured a dispatcher servlet where i have used some xml namespace. its working fine but shows below error.
Error details:
Multiple annotations found at this line:
- Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-4.0.xsd). For more information, right click on the message in the Problems View and select "Show
Details..."
- Referenced file contains errors (http://www.springframework.org/schema/context/spring-context-4.0.xsd). For more information, right click on the message in the Problems View and select "Show
Details..."
My Code:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
What is the cause of this error and how can I solve this?

I have resolved it by removing
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd from schema location.
my corrected code is:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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-4.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">

Related

Referenced file contains errors (org/springframework/beans/factory/xml/spring-tool-4.3.xsd)

When I validate aplicationContext.xml file I get this error:
Referenced file contains errors (project-aware://pm-master/org/springframework/beans/factory/xml/spring-tool-4.3.xsd).
and here is xml file:
<?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:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
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.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<jpa:repositories base-package="com.jedlab.pm.dao" entity-manager-factory-ref="entityManagerFactory" transaction-manager-ref="transactionManager" />
</beans>
and spring data jpa version is 1.11.0.RELEASE.
When I remove the jpa:repositories line the error disappear.
How can I solve it?
If you are using eclipse then clearing cache from Windows-> Preferences -> Network Connections -> Cache will be helpful.

Cannot find the declaration of element 'beans' offline

Hi I have been working on this old project offline with Spring framework 3.2 and everything is working fine.
The error "cvc-elt.1: Cannot find the declaration of element 'beans'" only happened when i copied the project folders to another location and import them using the same workspace.
If i go online, then the error disappear. Any idea how can i make it work offline?
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:cache="http://www.springframework.org/schema/cache"
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.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd">
All the spring library are located in the Maven Dependencies.
The nature of your configuration looks to an external source for xml schema definitions. i.e.
http://www.springframework.org/schema/beans
You will have to store and access all of these definitions locally.

Why does DTD error "White spaces are required between publicId and systemI" occur with Spring XSD

In my application context file Eclipse shows the error:
Referenced file contains errors (http://www.springframework.org/schema/integration). applicationContext.xml line 1 XML Problem
looking at the error detail in Eclipse I see:
White spaces are required between publicId and systemId
According to other people with this problem it's related to the DOCTYPE which apparently must have a SYSTEM identifier.
Why in 2014 when DOCTYPE's are pretty much obsolete since we all use XSD instead of DTDs and there is no DOCTYPE in http://www.springframework.org/schema/integration (or should there be) does this error occur?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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:jee="http://www.springframework.org/schema/jee"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:mail="http://www.springframework.org/schema/integration/mail"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/integration/mail
http://www.springframework.org/schema/integration/mail/spring-integration-mail-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-3.0.xsd
http://www.springframework.org/schema/context/spring-context.xsd">
Thanks
You have to move spring-context.xsd to its id:
<beans
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-3.0.xsd">

Spring-Data-JPA causes XSD validation error in Spring STS using XML configuration

Eclipse/STS reports errors using Spring 3.2.1 with Spring-data-jpa together.
I have some XML configuration files with the following header:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
I am using Spring 3.2.1 with Spring-Data-JPA 1.3.0 and Eclipse/STS is reporting this:
Referenced file contains errors
(http://www.springframework.org/schema/data/jpa)
This happens in every single XML configuration file that contains the data-jpa schema.
When I remove JPA from the XML config, everything is just fine.
Is my configuration wrong or what happens here?
Thanks!
Paul
Today there is not a http://www.springframework.org/schema/data/jpa/spring-jpa.xml file so you have to use http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd, but this file use http://www.springframework.org/schema/data/repository/spring-repository.xsd that does not exist too so you have to add the location of this schema in your context file:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.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/data/repository
http://www.springframework.org/schema/data/repository/spring-repository-1.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.2.xsd"

failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd'

While starting my Spring App, I am getting the following error :
WARNING: Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document
'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd', because
1) could not find the document;
2) the document could not be read;
3) the root element of the document is not <xsd:schema>.
My springapp-servlet.xml is as follows :
<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">
<bean name="/hello.htm" class="springapp.web.HelloController"/>
</beans>
Please suggest.
When I got this error message, it was merely because of a missing jar in my CLASSPATH. Some spring applications seem to be very hungry for spring jars. My app wound up needing all of these on the classpath:
${OTS_DIR}/org.springframework.aop-${VERSION}.jar:\
${OTS_DIR}/org.springframework.aspects-${VERSION}.jar:\
${OTS_DIR}/com.springsource.org.aopalliance-${AOPALLIANCE_VER}.jar:\
${OTS_DIR}/org.springframework.asm-${VERSION}.jar:\
${OTS_DIR}/org.springframework.beans-${VERSION}.jar:\
${OTS_DIR}/org.springframework.context-${VERSION}.jar:\
${OTS_DIR}/org.springframework.core-${VERSION}.jar:\
${OTS_DIR}/org.springframework.expression-${VERSION}.jar:\
${OTS_DIR}/org.springframework.jdbc-${VERSION}.jar:\
${OTS_DIR}/org.springframework.jms-${VERSION}.jar:\
${OTS_DIR}/org.springframework.orm-${VERSION}.jar:\
${OTS_DIR}/org.springframework.transaction-${VERSION}.jar:\
${OTS_DIR}/org.springframework.instrument-${VERSION}.jar
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Resources