SAXParseException when setting bean based predicate in CBR in XML DSL.
----------------------------------------------------------------------

                 Key: CAMEL-2044
                 URL: https://issues.apache.org/activemq/browse/CAMEL-2044
             Project: Apache Camel
          Issue Type: Bug
    Affects Versions: 1.6.1
         Environment: Camel 1.6, Windows, CBR with bean based Predicate
            Reporter: Torsten Mielke


The following Java DSL route works perfectly in Camel 1.6:

{code:java}
public void configure() throws Exception {              
                from("direct:In")
                  .choice()
                    .when().method("cbrBean", "checkHeader")
                  .to("mock:foo")
                  .otherwise()
                    .to("mock:bar")
                  .end();
            }
{code}
The bean code reads:
{code:java}
public static class MyCBRBean {

        public boolean checkHeader(Exchange exchange) {
                        logger.debug("checkHeader invoked.");
            Message inMsg = exchange.getIn();
            String foo = (String) inMsg.getHeader("foo");
            if (foo.equals("bar")) {
                logger.debug("checkHeader returning true");
                return true;
            } else {
                logger.debug("checkHeader returning false");
              return false;
            }
        }
    }
{code}

But using the corresponding XML config fails:

{code: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:amq="http://activemq.org/config/1.0";
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://activemq.apache.org/camel/schema/spring 
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
       http://activemq.org/config/1.0 
http://activemq.apache.org/snapshot-schema/activemq-core-5.0-SNAPSHOT.xsd";>
-->
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:amq="http://activemq.org/config/1.0";
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/camel/schema/spring 
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
       http://activemq.org/config/1.0 
http://activemq.apache.org/schame/core/activemq-core-5.0-SNAPSHOT.xsd";>

  <bean id="CBRBean" class="com.progress.cs.CBRBean"/>
  <camelContext id="camel" 
xmlns="http://activemq.apache.org/camel/schema/spring";>
        <route>
          <from uri="direct:In"/>
            <choice>
            <when>
                <method ref="CBRBean" method="checkHeader"/>
                <to uri="mock:foo"/>
            </when>
            <otherwise>
                <to uri="mock:bar"/>
            </otherwise>
          </choice>
        </route>
  </camelContext>
</beans>
{code}

with this error:

{code}
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid 
content was found starting with element 'method'. One of '{"http://activemq.
apache.org/camel/schema/spring":description, 
"http://activemq.apache.org/camel/schema/spring":expressionType, 
"http://activemq.apache.org/camel/schema
/spring":beanshell, "http://activemq.apache.org/camel/schema/spring":constant, 
"http://activemq.apache.org/camel/schema/spring":el, "http://activemq.a
pache.org/camel/schema/spring":groovy, 
"http://activemq.apache.org/camel/schema/spring":header, 
"http://activemq.apache.org/camel/schema/spring":jxpat
h, "http://activemq.apache.org/camel/schema/spring":javaScript, 
"http://activemq.apache.org/camel/schema/spring":expression, 
"http://activemq.apache.o
rg/camel/schema/spring":methodCall, 
"http://activemq.apache.org/camel/schema/spring":ognl, 
"http://activemq.apache.org/camel/schema/spring":php, "http
://activemq.apache.org/camel/schema/spring":python, 
"http://activemq.apache.org/camel/schema/spring":ruby, 
"http://activemq.apache.org/camel/schema/sp
ring":simple, "http://activemq.apache.org/camel/schema/spring":sql, 
"http://activemq.apache.org/camel/schema/spring":xpath, 
"http://activemq.apache.or
g/camel/schema/spring":xquery}' is expected.
        at 
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
        at 
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
        at 
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
        at 
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
        at 
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:429)
        at 
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3185)
        at 
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1831)
        at 
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:725)
        at 
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
        at 
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.ja
va:1693)
        at 
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
        at 
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
        at 
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
        at 
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
        at 
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)
        at 
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
        at 
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
        at 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
        ... 31 more
{code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to