Jaxb dataFormat don't works in spring DSL
I created a route to make unmarshall from xml files to java objects, however when I execute this one, the error below occur.
Caused by: javax.xml.bind.JAXBException: "com.redhat.training.model" doesnt contain ObjectFactory.class or jaxb.index
I don't understand the reason of problem because I created an annotated class basead in the JB421 course.
package com.redhat.training.model;
import java.io.Serializable;
import javax.xml.bind.annotation.*;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Order implements Serializable{
private static final long serialVersionUID = 5851038813219503043L;
@XmlAttribute
private String id;
@XmlAttribute
private String description;
@XmlAttribute
private double value;
@XmlAttribute
private double tax;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public double getValue() {
return value;
}
public void setValue(double value) {
this.value = value;
}
public double getTax() {
return tax;
}
public void setTax(double tax) {
this.tax = tax;
}
}
after that, I made a reference to this class using the tag in the camelContext.xml file.
I don't find any reference that I need to create an instance of ObjectFactory or put a file jaxb.index in the same package of annotated classes.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="xmlProcessor" class="com.redhat.training.processor.XmlProcessor" />
<camelContext id="camelContext-5934cd73-2041-4b43-aa3c-52f4f62aaeef"
trace="false" xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<jaxb id="jaxb" contextPath="com.redhat.training.model" ></jaxb>
</dataFormats>
<route id="_route1">
<from id="_from1" uri="file:files/xml"/>
<unmarshal ref="jaxb"/>
<to uri="bean:xmlProcessor" />
</route>
</camelContext>
</beans>