Hi

You cannot use jacksonXml for XML data binding.
That is JAXB, so don't change it.


On Mon, Oct 13, 2025 at 4:13 PM Bedürftig, Arne
<[email protected]> wrote:

> Hello,
>
> I want to use jacksonXml as the xmlDateFormat for my Rest bindings.
>
> restConfiguration()
>                 .bindingMode(RestBindingMode.json_xml) // or auto
>                 .jsonDataFormat("jackson")
>                 .xmlDataFormat("jacksonXml“)
>
> Note, I am also using Spring Boot and have the following dependency added.
>
> <dependency>
>     <groupId>org.apache.camel.springboot</groupId>
>     <artifactId>camel-jacksonxml-starter</artifactId>
> </dependency>
>
> camel-jaxb is not on the classpath.
>
> When I start my application, I get this:
>
> Caused by: java.lang.IllegalArgumentException: Cannot find
> RestBindingJaxbDataFormatFactory on classpath. Add camel-jaxb to classpath.
> at
> org.apache.camel.impl.engine.SimpleCamelContext.createRestBindingJaxbDataFormatFactory(SimpleCamelContext.java:635)
> ~[camel-base-engine-4.14.1.jar:4.14.1]
> at
> org.apache.camel.impl.engine.DefaultCamelContextExtension.lazyInitAndAdd(DefaultCamelContextExtension.java:1133)
> ~[camel-base-engine-4.14.1.jar:4.14.1]
> at
> org.apache.camel.impl.engine.DefaultCamelContextExtension.lambda$lazyAddContextPlugin$0(DefaultCamelContextExtension.java:1129)
> ~[camel-base-engine-4.14.1.jar:4.14.1]
> at
> org.apache.camel.impl.engine.DefaultContextPluginManager.getContextPlugin(DefaultContextPluginManager.java:43)
> ~[camel-base-engine-4.14.1.jar:4.14.1]
> at
> org.apache.camel.impl.engine.DefaultCamelContextExtension.getContextPlugin(DefaultCamelContextExtension.java:1104)
> ~[camel-base-engine-4.14.1.jar:4.14.1]
> at
> org.apache.camel.support.PluginHelper.getRestBindingJaxbDataFormatFactory(PluginHelper.java:451)
> ~[camel-support-4.14.1.jar:4.14.1]
> at
> org.apache.camel.support.PluginHelper.getRestBindingJaxbDataFormatFactory(PluginHelper.java:443)
> ~[camel-support-4.14.1.jar:4.14.1]
> at
> org.apache.camel.support.processor.RestBindingAdviceFactory.build(RestBindingAdviceFactory.java:115)
> ~[camel-support-4.14.1.jar:4.14.1]
> at
> org.apache.camel.reifier.rest.RestBindingReifier.createRestBindingAdvice(RestBindingReifier.java:90)
> ~[camel-core-reifier-4.14.1.jar:4.14.1]
> at
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:335)
> ~[camel-core-reifier-4.14.1.jar:4.14.1]
>
> When I add camel-jaxb, then I get this:
>
> Caused by: java.lang.ClassCastException: class
> org.apache.camel.component.jacksonxml.JacksonXMLDataFormat cannot be cast
> to class org.apache.camel.converter.jaxb.JaxbDataFormat
> (org.apache.camel.component.jacksonxml.JacksonXMLDataFormat and
> org.apache.camel.converter.jaxb.JaxbDataFormat are in unnamed module of
> loader 'app')
> at
> org.apache.camel.converter.jaxb.JaxbDataFormatConfigurer.configure(JaxbDataFormatConfigurer.java:21)
> ~[camel-jaxb-4.14.1.jar:4.14.1]
> at
> org.apache.camel.support.PropertyBindingSupport.setSimplePropertyViaConfigurer(PropertyBindingSupport.java:806)
> ~[camel-support-4.14.1.jar:4.14.1]
>
> Looking at the code, it seems like even though jacksonXml has been defined
> as the data format, it will still try to load the JaxbDataFormat via the
> RestBindingAdviceFactory.
>
> if (jaxb != null) {
>     // to setup JAXB we need to use camel-jaxb
>
> PluginHelper.getRestBindingJaxbDataFormatFactory(camelContext).setupJaxb(camelContext,
> config,
>         bc.getType(), bc.getTypeClass(),
>         bc.getOutType(), bc.getOutTypeClass(),
>         jaxb, outJaxb);
> }
>
> The variable jaxb is not null, because "jaxb =
> camelContext.createDataFormat(name);“ and it will be of type
> JacksonXMLDataFormat.
>
> Am I missing a configuration, or is Jackson XML not meant to work with
> Rest?
>
> Thank you in advance.
>
> Regards,
> Arne B.
> --
>
>
> ------------------------------------------------------------------------------
> Informationen (einschließlich Pflichtangaben und Datenschutzerklärungen)
> zu einzelnen, innerhalb der EU tätigen Gesellschaften und
> Zweigniederlassungen der CITTI-Gruppe finden Sie unter
> http://www.citti.de/html/pflichtangaben.html. Diese E-Mail enthält
> vertrauliche und/ oder rechtlich geschützte Informationen. Wenn Sie nicht
> der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
> informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail.
> Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist
> nicht gestattet.
>
> Please refer to http://www.citti.de/html/pflichtangaben.html for
> information (including mandatory corporate particulars and data protection
> declarations) on selected CITTI branches and group companies registered or
> incorporated in the European Union. This e-mail may contain confidential
> and/or privileged information. If you are not the intended recipient (or
> have received this e-mail in error) please notify the sender immediately
> and delete this e-mail. Any unauthorized copying, disclosure or
> distribution of the material in this e-mail is strictly forbidden.
>
> ------------------------------------------------------------------------------
>


-- 
Claus Ibsen

Reply via email to