Uploaded image for project: 'FUSE Mediation Router'
  1. FUSE Mediation Router
  2. MR-759

Unable to use language attribute with the expression node in Spring DSL

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.12.0.redhat-61379
    • 2.10.0.redhat-60024
    • None
    • None

    Description

      The following exception occurs when trying to set the language attribute on the expression node in Spring DSL:

      [pache.camel.spring.Main.main()] MainSupport                    INFO  Apache Camel 2.10.0.redhat-60024 stopping
      *************************************
      Error occurred while running main from: org.apache.camel.spring.Main
      java.lang.reflect.InvocationTargetException
      	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:606)
      	at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:440)
      	at java.lang.Thread.run(Thread.java:724)
      Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 40 in XML document from file [/Users/jsherman/Development/sandbox/camel-groovy-script/target/classes/META-INF/spring/camel-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 40; columnNumber: 42; cvc-complex-type.2.4.a: Invalid content was found starting with element 'camel:expression'. One of '{"http://camel.apache.org/schema/spring":description, "http://camel.apache.org/schema/spring":expressionDefinition, "http://camel.apache.org/schema/spring":constant, "http://camel.apache.org/schema/spring":el, "http://camel.apache.org/schema/spring":groovy, "http://camel.apache.org/schema/spring":header, "http://camel.apache.org/schema/spring":jxpath, "http://camel.apache.org/schema/spring":javaScript, "http://camel.apache.org/schema/spring":language, "http://camel.apache.org/schema/spring":method, "http://camel.apache.org/schema/spring":mvel, "http://camel.apache.org/schema/spring":ognl, "http://camel.apache.org/schema/spring":php, "http://camel.apache.org/schema/spring":property, "http://camel.apache.org/schema/spring":python, "http://camel.apache.org/schema/spring":ref, "http://camel.apache.org/schema/spring":ruby, "http://camel.apache.org/schema/spring":simple, "http://camel.apache.org/schema/spring":spel, "http://camel.apache.org/schema/spring":sql, "http://camel.apache.org/schema/spring":tokenize, "http://camel.apache.org/schema/spring":xpath, "http://camel.apache.org/schema/spring":xquery}' is expected.
      	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
      	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:530)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:444)
      	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
      	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
      	at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:186)
      	at org.apache.camel.spring.Main.doStart(Main.java:140)
      	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      	at org.apache.camel.main.MainSupport.run(MainSupport.java:141)
      	at org.apache.camel.main.MainSupport.run(MainSupport.java:332)
      	at org.apache.camel.spring.Main.main(Main.java:73)
      	... 6 more
      Caused by: org.xml.sax.SAXParseException; lineNumber: 40; columnNumber: 42; cvc-complex-type.2.4.a: Invalid content was found starting with element 'camel:expression'. One of '{"http://camel.apache.org/schema/spring":description, "http://camel.apache.org/schema/spring":expressionDefinition, "http://camel.apache.org/schema/spring":constant, "http://camel.apache.org/schema/spring":el, "http://camel.apache.org/schema/spring":groovy, "http://camel.apache.org/schema/spring":header, "http://camel.apache.org/schema/spring":jxpath, "http://camel.apache.org/schema/spring":javaScript, "http://camel.apache.org/schema/spring":language, "http://camel.apache.org/schema/spring":method, "http://camel.apache.org/schema/spring":mvel, "http://camel.apache.org/schema/spring":ognl, "http://camel.apache.org/schema/spring":php, "http://camel.apache.org/schema/spring":property, "http://camel.apache.org/schema/spring":python, "http://camel.apache.org/schema/spring":ref, "http://camel.apache.org/schema/spring":ruby, "http://camel.apache.org/schema/spring":simple, "http://camel.apache.org/schema/spring":spel, "http://camel.apache.org/schema/spring":sql, "http://camel.apache.org/schema/spring":tokenize, "http://camel.apache.org/schema/spring":xpath, "http://camel.apache.org/schema/spring":xquery}' is expected.
      	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
      	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
      	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
      	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
      	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
      	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:453)
      	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3232)
      	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1791)
      	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:741)
      	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:376)
      	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2717)
      	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
      	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
      	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
      	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
      	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:123)
      	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:237)
      	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:300)
      	at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
      	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
      	... 25 more
      *************************************
      

      The route being used looks as follows:

      <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.xsd">
      
        <bean id="user" class="com.example.User">
      	<property name="firstName" value="Jason"/>
        </bean>	
      
        <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
          <camel:route>
            <camel:from uri="timer://foo?fixedRate=true&amp;period=5000"/>
            <camel:setBody>
      	    <camel:expression language="groovy">user.firstName</camel:expression>
      	  </camel:setBody>
      	  <camel:transform>
      	    <camel:groovy>request.body.toUpperCase()</camel:groovy>
      	  </camel:transform>
      	  <camel:to uri="log:TEST"/>
          </camel:route>
        </camel:camelContext>
      
      </beans>
      

      The documentation eludes that this is the correct way to add an object as an attribute as Spring DSL does not support setting attributes in the same manner as Java DSL using .attribute(). See the documentation on Camel Groovy the section Attributes details this: http://camel.apache.org/groovy.html

      Attachments

        Activity

          People

            fbolton@redhat.com Fintan Bolton (Inactive)
            rhn-support-jsherman Jason Sherman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: