문제

I want to serialize the incoming message to XML. I'm starting from the camel-example-cxf-osgi example.

My Route:

JaxbDataFormat jaxb = new JaxbDataFormat();

from("cxf:bean:reportIncident")
 .convertBodyTo(InputReportIncident.class)
 .marshal(jaxb)
 .bean(new MyBean2())
 .transform(constant(ok));

But I'm getting error and I'm at a loss:

java.io.IOException: javax.xml.bind.JAXBException: class org.apache.camel.example.reportincident.InputReportIncident nor any of its super class is  known to this context.

Appreciate any help. Thx.

올바른 솔루션이 없습니다

다른 팁

Alternatively to the solution of Daniel, you could use

final JAXBContext jaxbContext = JAXBContext.newInstance(InputReportIncident.class);
final DataFormat jaxb = new JaxbDataFormat(jaxbContext);

This comes in handy if there is no ObjectFactory class. See Jaxb: How do I generate ObjectFactory class? for more general information about this subject.

You need to point your to the package where you keep your jaxb classes, something like

DataFormat jaxb = new JaxbDataFormat("com.acme.model");

The exception says that the jaxb context doesn't know how to marshal the class InputReportIncident.class.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top