Я использую два поля данных с одинаковыми позициями для двух разных атрибутов. Выдает исключение нулевого указателя. Может ли кто-нибудь помочь мне, как заставить его работать.
* CamelRoute.java *
public class ConverterRoute implements RoutesBuilder {
private static final String SOURCE_INPUT_PATH = "file://inbox?fileName=Source.txt";
private static final String SOURCE_OUTPUT_PATH = "file://outbox?fileName=file_$simple{date:now:yyyyMMddHHmmssSSS}.xml";
@Override
public void addRoutesToCamelContext(CamelContext context) throws Exception {
context.addRoutes(new RouteBuilder() {
public void configure() {
try {
DataFormat bindyFixed = new BindyCsvDataFormat(TestOne.class);
XmlFriendlyNameCoder nameCoder = new XmlFriendlyNameCoder("_-", "_");
Dom4JDriver dom4JDriver = new Dom4JDriver(nameCoder);
XStreamDataFormat xStreamDataFormat = new XStreamDataFormat();
xStreamDataFormat.setAliases(Collections.singletonMap("TEST_ONE", TestOne.class.getCanonicalName()));
//xStreamDataFormat.setXstreamDriver(dom4JDriver);
from(SOURCE_INPUT_PATH).
log("Received input from file and body is ${body}").
split().tokenize(System.lineSeparator()).
unmarshal(bindyFixed).
marshal(xStreamDataFormat).
log("After Marshalling and body is ${body}").
to(SOURCE_OUTPUT_PATH).log("Finished Transformation").
end();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
TestOne.java
@CsvRecord(separator = "\\|", skipField = true)
public class TestOne{
@DataField(pos = 3, required = true)
private String testId;
@Link
private TestTwo testTwo;
}
TestTwo.java
@CsvRecord(separator = "\\|", skipField = true)
public class TestTwo{
@DataField(pos = 3, required = true)
private String mockIt;
}
java.lang.NullPointerException: null
at org.apache.camel.dataformat.bindy.BindyCsvFactory.setDefaultValuesForFields(BindyCsvFactory.java:695) ~[camel-bindy-2.24.1.jar:2.24.1]
Добавлены сведения о маршруте конвертера HowЯ преобразовываю неструктурированные данные в xml.