以下是错误消息:
INFO [integration.ordXX.controller.PaymentOrder] (http-127.0.0.1:7070-1) ......Request Received for the ordergetPackagesToScan : [Ljava.lang.String;@6472d5b3
2017-06-20 14:57:02,989 ERROR [integration.ordXX.controller.PaymentOrder] (http-127.0.0.1:7070-1) Error in submit method: java.lang.ClassCastException: integration.ordXX.request.Order cannot be cast to javax.xml.bind.JAXBElement
at integration.ordXX.controller.PaymentOrder.submit(PaymentOrder.java:72) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_111]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_111]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_111]
at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_111]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) [spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) [spring-web-4.3.6.RELEASE.j
我们在这里使用spring API:
//JAXBElement<Order> element = (JAXBElement<Order>) convertor.unmarshal(ordXXReqMarshaller, orderXml);
Order ord=(Order)JAXBIntrospector.getValue(ordXXReqMarshaller.unmarshal(new StreamSource(new StringReader(orderXml))));
//order = element.getValue();
我们正在尝试使用上面的代码解组xml对象,但我们在代码之上会遇到异常。
当我们尝试用骆驼路线实现同样的目标时,它是成功的。
有人能帮助我吗?
使用骆驼路线
from("read from file")
.unmarshall()
.jaxb("package")
.process(new TestProcess())
.to()