Collegues, i have Camel context 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:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring-2.0.0.xsd">
<bean id="myFilter" class="com.ac.am.CamelComp.CurrentDateFileFilter"/>
<bean id="xsdProcessor" class="com.ac.am.CamelComp.MessProcessor"/>
<bean id="startPolicy" class="org.apache.camel.routepolicy.quartz2.CronScheduledRoutePolicy">
<property name="routeStartTime" value="0 0/5 * ? * 1-6 *" />
</bean>
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="uploadFromFtp" routePolicyRef="startPolicy">
<camel:from uri="sftp://
&throwExceptionOnConnectFailed=true
&consumer.delay=10000
&recursive=true"/>
<camel:to uri="bean:xsdProcessor"/>
<camel:to uri="file:sftp-inbound"/>
</route>
</camel:camelContext>
</beans>
I compiled pogramm using mvn clean compile assembly:single
.
When i run jar i receive next stack trace:
[32m13:37:27.923[0;39m [34mINFO [0;39m [32m[main][0;39m [36mo.s.b.f.xml.XmlBeanDefinitionReader[0;39m : Loading XML bean definitions from class path resource [camel-context.xml] [32m13:37:28.331[0;39m [31mWARN [0;39m [32m[main][0;39m [36mo.s.c.a.AnnotationConfigApplicationContext[0;39m : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 24 in XML document from class path resource [camel-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 66; cvc-complex-type.3.2.2: Attribute 'routePolicyRef' is not allowed to appear in element 'route'. Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 24 in XML document from class path resource [camel-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 66; cvc-complex-type.3.2.2: Attribute 'routePolicyRef' is not allowed to appear in element 'route'. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) .... at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524) at org.springframework.context.annotation.AnnotationConfigApplicationContext.(AnnotationConfigApplicationContext.java:84) at com.ac.am.AmeFtp.main(AmeFtp.java:32) Caused by: org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 66; cvc-complex-type.3.2.2: Attribute 'routePolicyRef' is not allowed to appear in element 'route'. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:429) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391) ... 16 more
lineNumber 23 is:
<route id="uploadFromFtp" routePolicyRef="startPolicy">
Could you help to fix it? Thank you.
UPDATE
camel
was added to route
, but nothing canges
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<camel:route id="uploadFromFtp" routePolicyRef="startPolicy">
<camel:from uri="sftp:......
&throwExceptionOnConnectFailed=true
&consumer.delay=10000
&recursive=true"/>
<camel:to uri="bean:xsdProcessor"/>
<camel:to uri="file:sftp-inbound"/>
</camel:route>
</camel:camelContext>
Stack:
Caused by: org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 72; cvc-complex-type.3.2.2: Attribute 'routePolicyRef' is not allowed to appear in element 'camel:route'.
lineNumber: 24;
is <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
Your camel namespace
xmlns:camel="http://camel.apache.org/schema/spring"
is mapped to the 2.0.0 version of the schema http://camel.apache.org/schema/spring/camel-spring-2.0.0.xsd (via xsi:schemaLocation), which does not have routePolicyRef attribute defined yet.
It looks like this attribute has only been added in 2.1.0
...
<xs:attribute name="routePolicyRef" type="xs:string"/>
...
hence, the error.
You can probably try to update your xsi:schemaLocation to point a proper version of schema (2.1.0 or later), taking that you are using an appropriate version of the framework itself.