1
votes

I am creating the following Camel 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:camel="http://camel.apache.org/schema/spring"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       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.xsd
       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">

    <camelContext xmlns="http://camel.apache.org/schema/spring">

      <routeContextRef ref="DoItRoute"/>

      <onException id="OnException">
         <exception>java.sql.SQLException</exception>
         <exception>java.lang.Exception</exception>
         <redeliveryPolicy maximumRedeliveries="0" />
         <to id="ErrorProcessor"                                  uri="bean:errorProcessor"/>
      </onException>

      <packageScan>
         <package>com.myself.route.doit</package>
         <excludes>*ExcludeMe*</excludes>
      </packageScan>

    </camelContext>

</beans>

In Eclipse, when I hover over <camelContext, it tells me

Element : camelContext
Content Model : (routeContextRef? | onException? | packageScan?)*

So my configuration seems to follow the schema.

However when I deploy it to Tomcat, I am getting the following exception:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 23 in XML document from class path resource [META-INF/spring/my-route.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 23; columnNumber: 20; cvc-complex-type.2.4.a: Invalid content was found starting with element 'packageScan'. One of '{"http://camel.apache.org/schema/spring":onException, "http://camel.apache.org/schema/spring":onCompletion, "http://camel.apache.org/schema/spring":intercept, "http://camel.apache.org/schema/spring":interceptFrom, "http://camel.apache.org/schema/spring":interceptSendToEndpoint, "http://camel.apache.org/schema/spring":restConfiguration, "http://camel.apache.org/schema/spring":rest, "http://camel.apache.org/schema/spring":route}' is expected.

What is going on here? Eclipse and Tomcat look at different XSD's? how do I fix this?

1

1 Answers

4
votes

Order matters!!.. Try to rearrange the tags as below , It will work.

 <camelContext xmlns="http://camel.apache.org/schema/spring">              

     <packageScan>
         <package>com.myself.route.doit</package>
         <excludes>*ExcludeMe*</excludes>
      </packageScan>

      <routeContextRef ref="DoItRoute"/>

      <onException id="OnException">
         <exception>java.sql.SQLException</exception>
         <exception>java.lang.Exception</exception>
         <redeliveryPolicy maximumRedeliveries="0" />
         <to id="ErrorProcessor"                                  uri="bean:errorProcessor"/>
      </onException>      

    </camelContext>

@refer http://camel.apache.org/schema/spring/camel-spring-2.15.0.xsd. (Tag sequence can be identified here)