getting error Invalid NamespaceHandler class org.springframework.data.jpa.repository.config.JpaRepositoryNameSpaceHandler - spring

While running spring i am getting error that
Unexpected exception parsing XML document from class path resource
[spring/tx-annotation-app-context.xml]; nested exception
is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class
[org.springframework.data.jpa.repository.config.JpaRepositoryNameSpaceHandler]
for namespace [http://www.springframework.org/schema/data/jpa]: problem with
handler class file or dependent class; nested exception is
java.lang.NoClassDefFoundError:
org/springframework/data/repository/config/RepositoryConfigurationExtension
Here is my file
<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:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<description>Example configuration to get you started.</description>
....
</beans>
Here is the screen shot of my included jars
What i am doing wrong with the namespace ?
Thanks

I think the problem is your using spring-data-commons-core version 1.1 and spring-data-jpa version 1.2. Align the versions of these libraries.
Looking at a pom.xml file from one of my projects I see.
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
and it uses spring-data-commons-core-1.4.0.RELEASE.jar
If you switch the packaging of spring-data-jpa to pom, it should download the necessary dependencies, then switch it back to jar.

Related

mule-module-spring-config and spring bean version mismatch

I am getting error :
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 5 in XML document from URL [jar:file:/<File path>/.m2/repository/org/mule/modules/mule-module-spring-config/3.9.2/mule-module-spring-config-
3.9.2.jar!/registry-bootstrap-mule-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 122; cvc-elt.1.a: Cannot find the declaration of element 'beans'.
at <TestclassPath>.<init>(<ClassName>.java:32)
while using mule-module-spring-config-3.9.2.jar and spring bean version 5.3.22.
but same code passes when we use Spring-bean version as 4.3.18.RELEASE.
SpringBeanTest.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd ">
....
</beans>
MuleTest.xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ajax="http://www.mulesoft.org/schema/mule/ajax"
xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:jdbc="http://www.mulesoft.org/schema/mule/ee/jdbc"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:core="http://www.mulesoft.org/schema/mule/core" version="CE-3.3.1"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:email="http://www.mulesoft.org/schema/mule/email"
xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"
xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/3.3/mule-json.xsd
http://www.mulesoft.org/schema/mule/ajax http://www.mulesoft.org/schema/mule/ajax/3.3/mule-ajax.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/3.3/mule-jdbc-ee.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.3/mule-jms.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.3/mule-vm.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.3/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/3.3/mule-email.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd">
<spring:beans>
<spring:import resource="classpath:SpringBeanTest.xml"/>
</spring:beans>
...
</mule>
I am new to spring , Could nayone help me in solving this issue.
Mule 3.x doesn't allow to use a different Spring Framework version than the one that is included in its distribution. Mule 3.9.2 includes for example includes Spring 4.1.9. Using a different version of Spring than the one included in the Mule version can cause unexpected errors -as you are experiencing- and is not supported. Mule 3.9.5, the final Mule 3.x release, supports Spring 4.3.29.
In particular Spring 5 is not supported by any version of Mule 3.x. See https://help.mulesoft.com/s/article/Spring-versions-throughout-each-version-of-Mule for more information of the Spring versions supported until Mule 3.9.2.
Mule 4 isolates the version of Spring used by the runtime from the one that is used by applications through the Spring Module, however it is not compatible with Mule 3 applications.

How to fix "Configuration Problem: Unable to locate Spring NamespaceHandler for XML schema namespace context"?

I was trying to run application in eclipse, it was running fine. I created jar using Maven install, and while running the jar I am getting the error "Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [appContext.xml]"
<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"
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">
<context:component-scan base-package="package"></context:component-scan>
...
Snap of project structure

Unable to locate Spring NamespaceHandler for XML schema namespace http://www.springframework.org/schema/data/solr

I am trying to integrate spring and Apache solr. For that i am trying NamespaceHandler http://www.springframework.org/schema/data/solr. But this giving me the following error.
Can any please help me.
<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:oxm="http://www.springframework.org/schema/oxm" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task"
xmlns:solr="http://www.springframework.org/schema/data/solr"
xsi:schemaLocation="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/oxm
http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/data/solr
http://www.springframework.org/schema/data/solr/spring-solr.xsd
">
This is leading to an error
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/data/solr]Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]
Thanx in advance for any help..
If this is a new project, you should start from Spring Boot and add Spring Data Solr into it. There are sample projects of how to do it. You can also check a real project using Spring Boot, and Spring Data Solr for auto-complete.

Drools integrated with spring faced with a xsd not found warning

I'm using Spring+Drools in my Web Application.The following is the drools modules configuration
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://drools.org/schema/drools-spring
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd"
default-autowire="byName">
<drools:kbase id="kbase1">
<drools:resources>
<drools:resource type="DRL" source="classpath:uniteStickyRules.drl"/>
</drools:resources>
</drools:kbase>
<drools:ksession id="ksession1" type="stateful" kbase="kbase1"/>
When I ran my application using this configuration in my junit project it worked, yet it came with the following problem when I startup my Web application. As a result, I couldnot find my kbase bean.
2012-03-29 12:55:48,402 WARN resolver.SpringPluggableSchemas - Could not find schema classpath:org/drools/container/spring/drools-service-spring.xsd for URI: http://drools.org/schema/drools-service-spring.xsd,
class path resource [org/drools/container/spring/drools-service-spring.xsd] cannot be resolved to URL because it does not exist
2012-03-29 12:55:48,413 WARN resolver.SpringPluggableSchemas - Could not find schema classpath:file:/C:/Users/Dan%20Diephouse/workspace/xfire/target/checkout/xfire-spring/target/test-generated/services.xsd for URI: http://xfire.codehaus.org/config/1.0,
class path resource [file:/C:/Users/Dan%20Diephouse/workspace/xfire/target/checkout/xfire-spring/target/test-generated/services.xsd] cannot be resolved to URL because it does not exist
You see, I didn't put the drools-service-spring.xsd in my .xml file. So I'm quite stuck with it. Any suggestions?

Where is the spring rabbit XSD (schema location for the rabbit: namespace)

http://static.springsource.org/spring-amqp/docs/1.0.x/reference/html/ mentions the rabbit: namespace, but never mentions what is the schema location. Googling (and naming conventions) ended up with:
http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
but this files does not exist. So where is the xsd?
Today XML schema located at:
http://www.springframework.org/schema/rabbit/spring-rabbit-1.3.xsd
http://www.springframework.org/schema/rabbit/spring-rabbit-1.4.xsd
http://www.springframework.org/schema/rabbit/spring-rabbit-1.5.xsd
Pick any you need!
As a temporary solution, I'm using this schema location to enable autocomplete. Otherwise it is located in the spring-rabbit jar (but the IDE does not detect it):
That is (from a comment from stacker):
I have the following at the top of my schema declaration:
<?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:rabbit="http://www.springframework.org/schema/rabbit"
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/rabbit
https://raw.github.com/SpringSource/spring-amqp/master/spring-rabbit/src/main/resources/org/springframework/amqp/rabbit/config/spring-rabbit-1.0.xsd">
I confirm Bozho's solution.
So basically at the top of my schema declaration I have the following:
<?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:rabbit="http://www.springframework.org/schema/rabbit"
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/rabbit
https://raw.github.com/SpringSource/spring-amqp/master/spring-rabbit/src/main/resources/org/springframework/amqp/rabbit/config/spring-rabbit-1.0.xsd">
Find a spring jar with META-INF/spring.schemas that has a reference to the rabbit xsd. The problem was resolved in my config by adding this maven dependency
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-amqp</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
or
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>1.1.1.RELEASE</version>
</dependency>
I know this question is older and my answer probably would not have worked at the time of the original question, but in case anyone happens on to this question after today...
The spring rabbit xsd is currently located here:
http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd
And to use it, you must have spring-rabbit-1.0.0.RELEASE.jar in your classpath.
It should be included in the AMQP jars. According to this thread you should use the snapshot version instead of RC1 and then you shouldn't receive any errors.

Resources