Define the data format before the routes. Check the schema or the spring example[1] [1]http://camel.apache.org/data-format.html
Taariq > On 10 Oct 2013, at 22:13, erj2code <p...@tetraconcepts.com> wrote: > > 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 > > First I tried adding the following XML tags to my applicationContext.xml (as > specified at http://camel.apache.org/json.html under "Using JSON in Spring > DSL") > > <dataFormats> > <json id="jack" library="Jackson"/> > </dataFormats> > > But when I add this to my applicationContext.xml, and run my Java code this > I get the following XmlBeanDefinitionStoreException message: > > 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. > > Moving these tags inside or outside of my camelContext yields the same error > (just a longer list of URLs when inside the camelContext). > > Is there something else I need to specify in my ApplicationContext.xml? > > Here is my current applicationContext.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: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"> > > <bean > > class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" > /> > <context:component-scan base-package="sample" /> > <context:annotation-config /> > > <camel:camelContext id="HelloWorldContext"> > > <camel:route> > > <camel:from > > uri="timer://hello.world.request.timer?fixedRate=true&period=10000" > /> > <camel:to uri="log:hello.world.request?level=INFO?showAll=true" /> > <camel:bean ref="helloWorld" /> > <camel:to uri="log:hello.world.response?level=INFO?showAll=true" /> > </camel:route> > > > <dataFormats> > <json id="jack" library="Jackson"/> > </dataFormats> > > </camel:camelContext> > > <bean id="jms" > class="org.apache.activemq.camel.component.ActiveMQComponent"> > <property name="configuration" ref="jmsConfig" /> > </bean> > > <bean id="jmsConfig" > class="org.apache.camel.component.jms.JmsConfiguration"> > <property name="connectionFactory" ref="jmsConnectionFactory" /> > <property name="transacted" value="false" /> > <property name="concurrentConsumers" value="1" /> > </bean> > > <bean id="jmsConnectionFactory" > class="org.apache.activemq.ActiveMQConnectionFactory"> > <property name="brokerURL" value="vm://localhost" /> > <property name="redeliveryPolicy" ref="redeliveryPolicy" /> > <property name="prefetchPolicy" ref="prefetchPolicy" /> > </bean> > > <bean id="prefetchPolicy" > class="org.apache.activemq.ActiveMQPrefetchPolicy"> > <property name="queuePrefetch" value="5" /> > </bean> > > <bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy"> > <property name="maximumRedeliveries" value="1" /> > <property name="backOffMultiplier" value="2" /> > <property name="initialRedeliveryDelay" value="2000" /> > <property name="useExponentialBackOff" value="true" /> > </bean> > > </beans> > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Get-BeanCreationException-when-try-to-add-Jackson-Library-to-my-applicationContext-xml-tp5741314.html > Sent from the Camel - Users mailing list archive at Nabble.com.