According to Camel documentation, I create JaxbDataFormat (example code in documentation uses non-existing constructor, though?)
@Override
public void configure() throws Exception {
JaxbDataFormat jaxbDataFormat = new JaxbDataFormat();
jaxbDataFormat.setContextPath("somepackage");
I have pom-dependency
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jaxb</artifactId>
<version>2.18.3</version>
</dependency>
Doesn't work : "ConvertBody... because of Data format 'jaxb' could not be created."
Could somebody please give an example code how jaxb conversions are supposed to work with Camel. I have Camel in Action 2ed, but the example there uses XML-definde route. Procedure seems simple enough with XML - but I'm not very enthusiastic about using xml as programming language ;)
Using java 8.
............
Exception in thread "CamelMainRunController" java.lang.RuntimeException: org.apache.camel.FailedToCreateRouteException: Failed to create route route2 at: >>> Marshal[org.apache.camel.model.dataformat.JaxbDataFormat@57d7f108] <<< in route: Route(route2)[[From[activemq:gateway.queue]] -> [OnException... because of Data format 'jaxb' could not be created. Ensure that the data format is valid and the associated Camel component is present on the classpath at org.apache.camel.spring.boot.CamelSpringBootApplicationController.run(CamelSpringBootApplicationController.java:74) at org.apache.camel.spring.boot.CamelMainRunController$DaemonTask.run(CamelMainRunController.java:42) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route2 at: >>> Marshal[org.apache.camel.model.dataformat.JaxbDataFormat@57d7f108] <<< in route: Route(route2)[[From[activemq:gateway.queue]] -> [OnException... because of Data format 'jaxb' could not be created. Ensure that the data format is valid and the associated Camel component is present on the classpath at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1071) at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196) at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:984) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3401) at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3132) at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:183) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2961) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957) at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2980) at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2957) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2924) at org.apache.camel.main.Main.doStart(Main.java:129) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.main.MainSupport.run(MainSupport.java:138) at org.apache.camel.spring.boot.CamelSpringBootApplicationController.run(CamelSpringBootApplicationController.java:69) ... 2 more Caused by: java.lang.IllegalArgumentException: Data format 'jaxb' could not be created. Ensure that the data format is valid and the associated Camel component is present on the classpath at org.apache.camel.model.DataFormatDefinition.getDataFormat(DataFormatDefinition.java:107) at org.apache.camel.model.DataFormatDefinition.getDataFormat(DataFormatDefinition.java:88) at org.apache.camel.model.MarshalDefinition.createProcessor(MarshalDefinition.java:177) at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:545) at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:506) at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:222) at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1068) ... 17 more
camel-jaxb
available on your classpath at runtime? How do you run Camel? Standalone? Spring? Blueprint/OSGi? – Alessandro Da Rugna