Hi The jackson-xml module was added much later to Camel, after rest-dsl and so on. So it was not on the table to use this instead of jaxb. And there are tools that can generate POJO classes with both kind of annotations, or I assume you can let jackson json understand the JAXB annotations instead of its own.
However, maybe we can add support for using jacksonXml as well. https://issues.apache.org/jira/browse/CAMEL-22542 On Mon, Oct 13, 2025 at 4:25 PM Bedürftig, Arne <[email protected]> wrote: > Hi > > Thank you for the quick response. Are there any plans to change that? How > is this xmlDataFormat configuration option meant to be used, if I cannot > use anything else but JAXB? > > My use-case: > > I generate the models with Swagger Code generator and the Java lang > generator. The one that works best only includes JSON annotations. JAXB > doesn’t serialize those models without further effort, which is why I > wanted to try JacksonXML. > > I would like to stick with generated models and use auto-binding if > possible. > > Do you suggest continuing with JAXB in Rest or to turn off binding in > implement serialization myself? > > -- > > Von: Claus Ibsen <[email protected]> > Datum: Montag, 13. Oktober 2025 um 16:16 > An: [email protected] <[email protected]> > Betreff: [[email protected]] > Re: Rest with Binding xml or auto always depends on JAXB through > RestBindingAdviceFactory PluginHelper.getRestBindingJaxbDataFormatFactory > > 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 > > ------------------------------------------------------------------------------ > 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
