Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/aop] - spring

I m using Spring AOP architecture for Logging and Transaction management.we are using WSO2-ESB container for deploying our service.
Here the XML file which we try to read using ClassPathXmlApplicationContext().
<?xml version="1.0" encoding="UTF-8"?>
<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:xsi="http://www.w3.org/2001/XMLSchema-instance"
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.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<!-- Complete AOP implementation -->
<aop:aspectj-autoproxy />
<!-- Aspect -->
<bean id="logAspect" class="x.y.z.logging.aspect.LoggingAspect" />
<aop:config>
<aop:aspect id="aspectLoggging" ref="logAspect" >
<!-- #Before -->
<aop:pointcut id="pointCutBefore"
expression="execution(* *(..))" />
<aop:before method="logBefore" pointcut-ref="pointCutBefore" />
<!-- #After -->
<aop:pointcut id="pointCutAfter"
expression="execution(* *(..))" />
<aop:after method="logAfter" pointcut-ref="pointCutAfter" />
<!-- #AfterReturning -->
<aop:pointcut id="pointCutAfterReturning"
expression="execution(* *(..))" />
<aop:after-returning method="logAfterReturning" returning="result"
pointcut-ref="pointCutAfterReturning" />
<!-- #AfterThrowing -->
<aop:pointcut id="pointCutAfterThrowing"
expression="execution(* *(..))" />
<aop:after-throwing method="logAfterThrowing" throwing="error"
pointcut-ref="pointCutAfterThrowing" />
</aop:aspect>
</aop:config>
</beans>
Actual problem occurred when i start my WSO2-ESB server.
Here i have attached Stacktrace :
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/aop]
Offending resource: file [C:\WSO2\Temp\WSO2ES~1.0\.\repository\conf\bundle-config\logger-aspect.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:316)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1416)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
at com.mi.logging.core.SpringLoggerUtil.setApplicationContext(SpringLoggerUtil.java:37)
at com.mi.logging.aspect.activator.LogAspectActivator.start(LogAspectActivator.java:16)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 9 more
I m using spring.3.2.5 version and I have reassured that all dependent jar are on classpath.
Please help to resolve this issue. If you have any suggestion or solution then please let me know.
Thnx in advance.

This problem occurred due to it can't find the path/location of spring-aop-3.0.xsd from spring.framework_3.1.0.wso2v1.jar, which is provided by the WSO2-ESB.
It can be resolved by two ways :
1) You can add your latest version of spring and set the priority of that jar files. Reference
2) You have to just simply follow the steps described below.
You have to add some files into META-INF folder of spring.framework_3.1.0.wso2v1.jar file.
Steps are shown below.
i) Create a new file spring.schemas and add the content shown below.
http\://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd
http\://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd
http\://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd
http\://www.springframework.org/schema/aop/spring-aop-3.1.xsd=org/springframework/aop/config/spring-aop-3.1.xsd
http\://www.springframework.org/schema/aop/spring-aop-3.2.xsd=org/springframework/aop/config/spring-aop-3.2.xsd
http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.2.xsd
ii) Create a new file spring.handlers and add the content shown below.
http\://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler
iii) Create a new file spring.tooling and add the content shown below.
# Tooling related information for the aop namespace
http\://www.springframework.org/schema/aop#name=aop Namespace
http\://www.springframework.org/schema/aop#prefix=aop
http\://www.springframework.org/schema/aop#icon=org/springframework/aop/config/spring-aop.gif

Related

Spring Integration upgrade from 5.2.x to 5.3 problem

I wanted to upgrade Spring boot version from 2.2.7.RELEASE to 2.3.0.RELEASE, I am using also Spring integration file with XML configuration (see below).
when starting my application, a NullPointerException is thrown. After debugging the issue, the root cause was the creation of the bean file:inbound-channel-adapter. The interesting thing is that only this type of beans which cause this issue and all other ones doesn't.
Did anyone had a similar issue? Anyone can help transforming this XML to Java configuration style? Thanks in advance.
<?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:int="http://www.springframework.org/schema/integration"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
<bean id="compositeFilter" class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
<list>
<ref bean="ignoreHiddenFileListFilter"/>
<ref bean="acceptOnceFileListFilter"/>
<ref bean="extensionFileFilter"/>
</list>
</constructor-arg>
</bean>
<!-- upload folder listener -->
<file:inbound-channel-adapter id="uploadFilesScanner" directory="${integration.upload-folder}" filter="compositeFilter">
<int:poller fixed-rate="${integration.poller-rate:10000}"/>
</file:inbound-channel-adapter>
<file:outbound-gateway request-channel="uploadFilesScanner" reply-channel="batchFilesScanner" directory="${integration.directory}" delete-source-files="true"/>
<!-- 1) Scan for files -->
<file:inbound-channel-adapter id="batchFilesScanner" directory="${integration.directory}" filter="compositeFilter">
<int:poller fixed-rate="5000"/>
</file:inbound-channel-adapter>
<!-- 2) move the file to processing -->
<file:outbound-gateway request-channel="batchFilesScanner" reply-channel="batchFilesProcessing" directory="${integration.processing-folder}" delete-source-files="true"/>
<!-- 3) transform csv file -->
<int:service-activator input-channel="batchFilesProcessing" output-channel="batchFilesTran" ref="batchTransformerTask" method="execute"/>
<!-- 4) move the file to archive folder -->
<file:outbound-gateway request-channel="batchFilesTran" reply-channel="batchFilesArchive" directory="${integration.archive-folder}" delete-source-files="true"/>
<int:service-activator input-channel="batchFilesArchive" ref="cleanupHelper" method="execute"/>
<!-- Transformer task channel configuration -->
<task:executor id="batchFilesTranTaskExecutor" pool-size="1" rejection-policy="CALLER_RUNS" queue-capacity="1"/>
<int:channel id="batchFilesTran">
<int:dispatcher load-balancer="round-robin" task-executor="batchFilesTranTaskExecutor" failover="false"/>
</int:channel>
<int:service-activator input-channel="errorChannel" ref="intErrorHandler" method="execute"/>
</beans>
NullPointerException:
Caused by:
java.lang.NullPointerException
at org.springframework.integration.support.utils.IntegrationUtils.obtainComponentName(IntegrationUtils.java:205)
at org.springframework.integration.graph.IntegrationGraphServer$NodeFactory.sourceNode(IntegrationGraphServer.java:399)
at org.springframework.integration.graph.IntegrationGraphServer.lambda$pollingAdapters$1(IntegrationGraphServer.java:216)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
at org.springframework.integration.graph.IntegrationGraphServer.pollingAdapters(IntegrationGraphServer.java:221)
at org.springframework.integration.graph.IntegrationGraphServer.buildGraph(IntegrationGraphServer.java:184)
at org.springframework.integration.graph.IntegrationGraphServer.onApplicationEvent(IntegrationGraphServer.java:116)
at org.springframework.integration.graph.IntegrationGraphServer.onApplicationEvent(IntegrationGraphServer.java:67)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
... 88 more
The issue is confirmed. The FileReadingMessageSourceFactoryBean doesn't populate a beanName into a FileReadingMessageSource it produces.
Your config is too big to convert it over here immediately. Consider to follow docs: https://docs.spring.io/spring-integration/docs/current/reference/html/overview.html#programming-tips
A Java & Annotations configuration analog for the <file:inbound-channel-adapter> is like this:
#Bean
#InboundChannelAdapter
public FileReadingMessageSource fileReadingMessageSource() {
...
}
See more info here: https://docs.spring.io/spring-integration/docs/current/reference/html/configuration.html#annotations
With Java DSL it is just a matter to take an IntegrationFlows.from(MessageSource) factory and follow its builder for the rest:
https://docs.spring.io/spring-integration/docs/current/reference/html/dsl.html#java-dsl-inbound-adapters
I stick to the Spring Boot version 2.3.0 and only override the version of SI to 5.3.1 release and it worked. The Exception is gone.

Unable to start camel spring context in jboss environment

I have created a camel spring file as below. The file uses a routebuilder class already present in the code. Its not able to parse the xml and hence the applicationcontext is unable to start properly.
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:camel="http://www.camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
spring-beans.xsd http://www.springframework.org/schema/tx
spring-tx.xsd http://www.springframework.org/schema/context
spring-context.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.19.1.xsd">
<bean id="ValidateAndUpdateBatchRoute" class="com.camelkafka.ValidateAndUpdateBatchRoute" />
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<camel:routeBuilder ref="ValidateAndUpdateBatchRoute" />
</camel:camelContext>
</beans>
But when start jboss it throws the following exception.
16:09:20,181 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/RDAWorkFlowEjb-17.6]] (ServerService Thread Pool -- 125) JBWEB000289: Servlet startup threw load() exception: org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 68; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'camel:camelContext'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
at org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:132)
at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:390)
at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:322)
at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:281)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:446)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3271)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1993)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:724)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:283)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1653)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:845)
at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:768)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:230)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:285)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:429) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:612) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:513) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
at com.alu.oss.mdf.rda.workflow.util.WorkFlowUtil.initialize(WorkFlowUtil.java:73) [classes:]
at com.alu.oss.mdf.rda.workflow.servlets.StartUpServlet.init(StartUpServlet.java:18) [classes:]
at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-2.jar:1.0.2.Final-redhat-2]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1194) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1100) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3593) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3802) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [rt.jar:1.8.0_102]
at java.util.concurrent.FutureTask.run(Unknown Source) [rt.jar:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_102]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_102]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.2.Final-redhat-1.jar:2.1.2.Final-redhat-1]
Unable to understand what is missing from the spring xml file. I have added the dependency in the module.xml of jboss for third party dependency as well.
The camelContext spring xml file should look similar to 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:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation=" http://www.springframework.org/schema/beans spring-beans.xsd
http://camel.apache.org/schema/spring camel-spring.xsd">
<bean id="jbossResolver" class="org.apacheextras.camel.jboss.JBossPackageScanClassResolver"/>
<bean id="ValidateAndUpdateBatchRoute" class="com.camelkafka.ValidateAndUpdateBatchRoute" />
<camel:camelContext>
<camel:routeBuilder ref="ValidateAndUpdateBatchRoute" />
</camel:camelContext>
</beans>
The dependency for camel-core and camel-spring should be as follows:
Camel-core- located at org/apache/camel/core:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.apache.camel.core">
<resources>
<resource-root path="camel-core-2.19.1.jar"/>
<resource-root path="jaxb-impl-2.2.11.jar"/>
<resource-root path="jaxb-core-2.2.11.jar"/>
<resource-root path="camel-jboss6-2.18.0.jar"/>
<resource-root path="camel-spring-2.19.1.jar"/>
</resources>
<dependencies>
<module name="org.springframework"/>
<module name="org.slf4j"/>
<module name="javax.xml.bind.api"/>
<module name="javax.api"/>
<module name="sun.jdk" />
<module name="org.jboss.vfs" />
</dependencies>
</module>
Next camel-spring- located at org/apache/camel/spring:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.apache.camel.spring">
<resources>
<resource-root path="camel-spring-2.19.1.jar"/>
<resource-root path="camel-jboss6-2.18.0.jar"/>
</resources>
<dependencies>
<module name="org.springframework"/>
<module name="org.slf4j"/>
<module name="javax.xml.bind.api"/>
<module name="javax.api"/>
<module name="org.apache.camel.core" />
<module name="org.jboss.vfs" />
</dependencies>
</module>
Also make sure to add camel-spring.xsd into classpath as well. This should be started as shown below:
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camelContext.xml");
This is worked fine for me. Hope it helps others as well for using camel in jboss EAP.
For some reason the camel thirdparty jars configured in jboss was not picked up. I had to put the jars in WEB-INF/lib for it to work.
Change the location of http://www.camel.apache.org/schema/spring namespace to use http://camel.apache.org/schema/spring/camel-spring-2.19.1.xsd! (without the www.)

spring data jpa and commons compatibility

I meet an exception running a project using spring data jpa
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 18 in XML document from class path resource [META-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/spring-jpa.xsd; lineNumber: 18; columnNumber: 51; src-resolve: Cannot resolve the name 'repository:repositories' to a(n) 'type definition' component.
I read through many docs and blogs and I think this is possibly caused by incompatibility of spring data jpa and spring data commons package versions.
Now I'm using
spring-data-commons-core-1.4.1.Release
spring-data-commons-1.10.0.release
spring-data-jpa-1.8.0.
Any suggestion on the version control to get rid of such error?
Also I would like to ask for suggestions how to make such version control easier(any website, docs or tools). Thanks for advice in advance.
Below is the namespace I use
<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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:repository="http://www.springframework.org/schema/data/repository"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository.xsd">
The repository:repository is not from my applicationContext.xml. I did use jpa:repository as
<jpa:repositories base-package="com.canreef.calendar"/>
I found this roots in spring-repository.xsd
In spring-jpa.xsd there is a line with ref to repository:auditing-attributes:
<xsd:element name="auditing">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.data.jpa.domain.support.AuditingEntityListener" />
<tool:exports type="org.springframework.data.auditing.AuditingHandler" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup ref="repository:auditing-attributes" />
</xsd:complexType>
</xsd:element>
While in spring-repository.xsd there is the bean:
-<xsd:attributeGroup name="auditing-attributes">
-<xsd:attribute name="auditor-aware-ref">
-<xsd:annotation>
-<xsd:documentation>
<![CDATA[ References a bean of type AuditorAware to represent the current principal. ]]>
</xsd:documentation>
-<xsd:appinfo>
-<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.domain.AuditorAware"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
...omitted...
</xsd:attributeGroup>
Therefore this should be caused by not able to fetch the repository.xsd.

Having trouble with content based routing in Camel with a CXFRS endpoint and xPath

I am trying to create a route that is determined by the content in the REST payload using xPath. I have been successful in using routing based on the message header:
<when>
<simple>${headers.operationName} == 'createContainerOutput'</simple>
<bean ref="containerOutputProcessor"/>
</when>
which properly invokes the containerOutputProcessor...
but for this xPath route:
<when>
<xpath>/*[local-name()='order-request']/#type='TrayOutput'</xpath>
<bean ref="containerOutputProcessor"/>
</when>
I get the the exception:
org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.w3c.dom.Document with value [com.mmi.ws.ContainerOutputOrderRequest#6290dc]
for this payload
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order-request type="TrayOutput">
<parameter name="orderName">Example Tray Output Order</parameter>
<parameter name="enableScan">true</parameter>
<parameter name="autoStart">false</parameter>
<parameter name="priority">3</parameter>
<item barcode="23990001"/>
<item barcode="23990002"/>
</order-request>
Is this type of routing a good idea? Is there a better way to route based on what type of order-request is being submitted?
Thanks for any help/guidance you may have for me!
Here is the complete context
<?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:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:cxf="http://camel.apache.org/schema/cxf"
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/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<!-- enable Spring #Component scan -->
<context:component-scan base-package="com.mmi.ws"/>
<!-- web service beans -->
<bean id="containerOutputWS" class="com.mmi.ws.service.impl.ContainerOutputWSImpl" />
<bean id="containerTypesWS" class="com.mmi.ws.service.impl.ContainerTypesWSImpl" />
<!-- processor beans -->
<bean id="containerOutputProcessor" class="com.mmi.ws.service.ContainerOutputProcessor" />
<bean id="containerTypesProcessor" class="com.mmi.ws.service.ContainerTypesProcessor" />
<bean id="unsupportedPathProcessor" class="com.mmi.ws.service.UnsupportedPathProcessor" />
<!-- Define the real JAXRS back end service -->
<jaxrs:server id="restService"
address="http://localhost:9998/sc"
staticSubresourceResolution="true">
<jaxrs:serviceBeans>
<ref bean="containerOutputWS"/>
<ref bean="containerTypesWS"/>
</jaxrs:serviceBeans>
</jaxrs:server>
<!-- define the restful server and client endpoints -->
<cxf:rsServer id="rsServer" address="http://localhost:9999/sc" loggingFeatureEnabled="true" loggingSizeLimit="20">
<cxf:serviceBeans >
<ref bean="containerOutputWS"/>
<ref bean="containerTypesWS"/>
</cxf:serviceBeans>
</cxf:rsServer>
<cxf:rsServer id="rsClient" address="http://localhost:9998/sc" loggingFeatureEnabled="true" loggingSizeLimit="20">
<cxf:serviceBeans >
<ref bean="containerOutputWS"/>
<ref bean="containerTypesWS"/>
</cxf:serviceBeans>
</cxf:rsServer>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!--
any classes in the below 'packageScan'packages that extends RouteBuilder
will be added as a camel route. At least one route is required to start the cxf web service
-->
<packageScan>
<package>com.mmi.ws</package>
</packageScan>
<dataFormats>
<xstream id="xstream-utf8" encoding="UTF-8"/>
<xstream id="xstream-default"/>
</dataFormats>
<!-- route starts from the cxf webservice -->
<route streamCache="true">
<from uri="cxfrs://bean://rsServer"/>
<log message="XML payload to send to REST WS:${body}" />
<setHeader headerName="CamelCxfRsUsingHttpAPI"><constant>True</constant> </setHeader>
<choice>
<when>
<simple>${headers.operationName} == 'getContainers'</simple>
<bean ref="containerTypesProcessor"/>
</when>
<when>
<xpath>/*[local-name()='order-request']/#type='TrayOutput'</xpath>
<bean ref="containerOutputProcessor"/>
</when>
<otherwise>
<bean ref="unsupportedPathProcessor"/>
<to uri="cxfrs://bean://rsClient"/>
</otherwise>
</choice>
</route>
</camelContext>
</beans>
and the web service class:
#Path("/container/output/")
public class ContainerOutputWSImpl
{
#POST
#Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
#Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ContainerOutputView createContainerOutput(ContainerOutputOrderRequest containerOutput) {
// TODO Auto-generated method stub
return new ContainerOutputView();
}
}
and finally, the xml payload and error stack:
Address: http://localhost:9999/sc/container/output/
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/xml
Headers: {accept-encoding=[gzip,deflate], connection=[keep-alive], Content-Length=[384], content-type=[application/xml], Host=[localhost:9999], User-Agent=[Apache-HttpClient/4.1.1 (java 1.5)]}
Payload: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order-request type="TrayOutput">
<parameter name="orderName">Example Tray Output Order</parameter>
<parameter name="enableScan">true</parameter>
<parameter name="autoStart">false</parameter>
<parameter name="priority">3</parameter>
<item barcode="23990001"/>
<item barcode="23990002"/>
</order-request>
--------------------------------------
[ERROR] 2013-02-07 17:53:37.059 [qtp27633254-28: DefaultErrorHandler] Failed delivery for (MessageId: ID-PWY-EHANSEN-3070-1360288389778-0-2 on ExchangeId: ID-PWY-EHANSEN-3070-1360288389778-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.RuntimeCamelException: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.w3c.dom.Document with value [com.mmi.ws.ContainerOutputOrderRequest#9fbbe5]
org.apache.camel.RuntimeCamelException: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.w3c.dom.Document with value [com.mmi.ws.ContainerOutputOrderRequest#9fbbe5]
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1271)
at org.apache.camel.builder.xml.XPathBuilder.getDocument(XPathBuilder.java:1027)
at org.apache.camel.builder.xml.XPathBuilder.doInEvaluateAs(XPathBuilder.java:850)
at org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.java:757)
at org.apache.camel.builder.xml.XPathBuilder.matches(XPathBuilder.java:145)
at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:66)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:334)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
at org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.asyncInvoke(CxfRsInvoker.java:87)
at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.performInvocation(CxfRsInvoker.java:57)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:355)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:319)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1074)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1010)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:722)
Before the content based router, you can convert the message to take out the payload from the internal CXF list. There is a trick with the simple language to grab the first index from the list:
<transform>
<simple>${body[0]}</simple>
</transform>
<choice>
...
Do you have camel-jaxb on the classpath. If so it may work out of the box without that trick. Not sure though, as CXF is a bit special. Also dependes on what version of Camel / CXF you use. You should really mention this when you ask questions!

spring mongo data exception, with configuring via xml

hopefully someone can help me with this. I am working on a spring-data with mongo, but somehow it gives me a runtime error:
Oct 02, 2012 8:15:24 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext#54d57bcb: startup date [Tue Oct 02 20:15:24 SGT 2012]; root of context hierarchy
Oct 02, 2012 8:15:24 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [mongodb/configuration/mongo-config.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [mongodb/configuration/mongo-config.xml]; nested exception is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.data.mongodb.config.MongoNamespaceHandler] for namespace [http://www.springframework.org/schema/data/mongo]: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/config/RepositoryConfigurationExtension
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:535)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at parseXML.main(parseXML.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.data.mongodb.config.MongoNamespaceHandler] for namespace [http://www.springframework.org/schema/data/mongo]: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/config/RepositoryConfigurationExtension
at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:139)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1426)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1421)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
... 19 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/repository/config/RepositoryConfigurationExtension
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.getDeclaredConstructor(Class.java:2002)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104)
at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:129)
... 26 more
Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.config.RepositoryConfigurationExtension
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 32 more
My mongo-config.xml:
<?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:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<mongo:db-factory dbname="testuserexample" host="localhost" port="27017" />
<bean id="mongoTemplate">
<constructor-arg ref="mongoDbFactory" />
</bean>
<mongo:repositories base-package="mongodb.repository" />
Thanks in advance!
If you are using Maven you should add depency to the spring-data-mongodb library
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.1.0.M1</version>
</dependency>
I get the same error too.
I found a solution for me.
The problem was that I've changed my pom.xml and setted last version explicitly (1.1.0.RELEASE) for both dependencies :
spring-data-mongodb
spring-data-commons-core
I get the same exception : NoClassDefFoundError: ...RepositoryConfigurationExtension
I've removed the second dependence in my pom.xml because the first "spring-data-mongodb" add an implicite dependence for the second one.
So, now Maven grab automatically spring-data-commons-core dependence (1.4.0.RELEASE) and it works fine!
If you are using Maven this is the only dependancy that is required:-
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
Configuration needed in the application context file:-
<bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
<property name="host" value="localhost" />
</bean>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongo" />
<constructor-arg value="test" />
</bean>

Resources