COnvert from JSON to POJO fails with Camel

Viewed 189

I am trying to convert a simple JSON to POJO with Apache Camel. Unfortunately I getan error when converting:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `de.kvwl.tssImport.TestClass` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (BufferedInputStream); line: 1, column: 2]

My JSON-file looks like this:

{"testAttr":"testValue"}

My POJO:

@Data
@AllArgsConstructor
public class TestClass {
    private String testAttr;
}

My Camel-route:

JacksonDataFormat jsonDataFormat = new JacksonDataFormat(TestClass.class);
        from("direct:loadConfig")
                .pollEnrich("file://" + dir + "/?filename=TssImport.json&noop=true")
                .log("${body}")
                .unmarshal(jsonDataFormat)
                .process(new MyProcessor());

Interestingly the Code completes successfully if I remove the outter braces from my JSON-file like:

"testAttr":"testValue"

In my opinion this can't be right cause it is no valid JSON-format. Do you guys have any ideas to fix my problem?

0 Answers
Related