Hi,
I am trying to use jaxb inside Service Mix from one of my marshallers, in
order to convert the message source to an object.
The content of my NormalizedMessage is of
class org.apache.servicemix.jbi.jaxp.StaxSource and I use a snippet like the
following:
Unmarshaller u = contextManager.getUnmarshaler(clazz);
Source content = in.getContent();
result = u.unmarshal(content);
This results in the following Exception:
Caused by: java.lang.NullPointerException
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.expectText(UnmarshallingContext.java:544)[43:org.apache.servicemix.bundles.jaxb-impl:2.1.12.2]
at
com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.processText(SAXConnector.java:178)[43:org.apache.servicemix.bundles.jaxb-impl:2.1.12.2]
at
com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:142)[43:org.apache.servicemix.bundles.jaxb-impl:2.1.12.2]
at
org.apache.servicemix.jbi.jaxp.StaxSource.parse(StaxSource.java:141)[65:servicemix-utils:1.3.0]
at
org.apache.servicemix.jbi.jaxp.StaxSource.parse(StaxSource.java:267)[65:servicemix-utils:1.3.0]
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)[43:org.apache.servicemix.bundles.jaxb-impl:2.1.12.2]
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:184)[43:org.apache.servicemix.bundles.jaxb-impl:2.1.12.2]
at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:214)[41:org.apache.servicemix.specs.jaxb-api-2.1:1.6.0]
However, if I convert the the StaxSource to a String using a
SourceTransformer before calling jaxb everything works great.
Unmarshaller u = contextManager.getUnmarshaler(clazz);
Source content = in.getContent();
SourceTransformer transformer = new SourceTransformer();
StringReader reader = new
StringReader(transformer.contentToString(in));
result = u.unmarshal(reader);
The snippet above works great.
Any ideas what might be causing this issue?
--
*Ioannis Canellos*
http://iocanel.blogspot.com
Integration Engineer @ Upstream S.A. <http://www.upstreamsystems.com>