Note that there are some explanatory texts on larger screens.

plurals
  1. POGet BeanCreationException when try to add Jackson Library
    text
    copied!<p>I have a simple Hello World example that passes a Map to Camel and displays the values to the console via Log4J. I want to expand this example to render this map in JSON by adding the Jackson library to my Camel applicationContext.xml </p> <p>First I tried adding the following XML tags to my applicationContext.xml (as specified at <a href="http://camel.apache.org/json.html" rel="nofollow">http://camel.apache.org/json.html</a> under "Using JSON in Spring DSL") </p> <pre><code>&lt;camel:dataFormats&gt; &lt;camel:json id="jack" library="Jackson"/&gt; &lt;/camel:dataFormats&gt; </code></pre> <p>But when I add this to my applicationContext.xml, and run my Java code I get the following XmlBeanDefinitionStoreException message: </p> <pre><code>cvc-complex-type.2.4.a: Invalid content was found starting with element 'dataFormats'. One of '{"http://camel.apache.org/schema/ spring":route}' is expected. </code></pre> <p>Moving these tags inside or outside of my camelContext yields the same error (just a longer list of URLs when inside the camelContext). </p> <p>Is there something else I need to specify in my ApplicationContext.xml? </p> <p>Here is my current applicationContext.xml:</p> <p>UPDATED: The following xml now works. Had to move the location of the dataFormats XML tags.</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;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:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt; &lt;bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" /&gt; &lt;context:component-scan base-package="sample" /&gt; &lt;context:annotation-config /&gt; &lt;camel:camelContext id="HelloWorldContext"&gt; &lt;camel:dataFormats&gt; &lt;camel:json id="jack" library="Jackson"/&gt; &lt;/camel:dataFormats&gt; &lt;camel:route&gt; &lt;camel:from uri="timer://hello.world.request.timer?fixedRate=true&amp;amp;period=10000" /&gt; &lt;camel:to uri="log:hello.world.request?level=INFO?showAll=true" /&gt; &lt;camel:bean ref="helloWorld" /&gt; &lt;camel:to uri="log:hello.world.response?level=INFO?showAll=true" /&gt; &lt;/camel:route&gt; &lt;/camel:camelContext&gt; &lt;bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent"&gt; &lt;property name="configuration" ref="jmsConfig" /&gt; &lt;/bean&gt; &lt;bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration"&gt; &lt;property name="connectionFactory" ref="jmsConnectionFactory" /&gt; &lt;property name="transacted" value="false" /&gt; &lt;property name="concurrentConsumers" value="1" /&gt; &lt;/bean&gt; &lt;bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"&gt; &lt;property name="brokerURL" value="vm://localhost" /&gt; &lt;property name="redeliveryPolicy" ref="redeliveryPolicy" /&gt; &lt;property name="prefetchPolicy" ref="prefetchPolicy" /&gt; &lt;/bean&gt; &lt;bean id="prefetchPolicy" class="org.apache.activemq.ActiveMQPrefetchPolicy"&gt; &lt;property name="queuePrefetch" value="5" /&gt; &lt;/bean&gt; &lt;bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy"&gt; &lt;property name="maximumRedeliveries" value="1" /&gt; &lt;property name="backOffMultiplier" value="2" /&gt; &lt;property name="initialRedeliveryDelay" value="2000" /&gt; &lt;property name="useExponentialBackOff" value="true" /&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload