Hello,

I get the following marshaling error when invoking my service. I am using CXF 2.1.1.

INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error: java.util.ArrayList
at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshalWithBridge(JAXBEncoderDecoder.java:249)
   at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:87)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:113) at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221) at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:74) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:278) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:252) at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
   at org.mortbay.jetty.Server.handle(Server.java:320)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
   at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
   at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
   at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[java.lang.ClassCastException: java.util.ArrayList]
at com.sun.xml.bind.v2.runtime.BridgeAdapter._adaptM(BridgeAdapter.java:118) at com.sun.xml.bind.v2.runtime.BridgeAdapter.adaptM(BridgeAdapter.java:105) at com.sun.xml.bind.v2.runtime.BridgeAdapter.marshal(BridgeAdapter.java:81)
   at com.sun.xml.bind.api.Bridge.marshal(Bridge.java:107)
   at com.sun.xml.bind.api.Bridge.marshal(Bridge.java:102)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshalWithBridge(JAXBEncoderDecoder.java:230)
   ... 21 more
Caused by: java.lang.ClassCastException: java.util.ArrayList
   at impl.services.adapters.MessageAdapter.marshal(MessageAdapter.java:15)
at com.sun.xml.bind.v2.runtime.BridgeAdapter._adaptM(BridgeAdapter.java:115)
   ... 26 more

My service has just one method implemented.

public List<Message> getMessages(String filter);

Message is an interface and I tied the interface to the implementation using JAXB XmlJavaTypeAdapter and my adapter code is shown below.

public class MessageAdapter extends XmlAdapter<MessageImpl, Message> {
   public MessageImpl marshal(Message v) throws Exception {
     return (MessageImpl)v;
   }
   public Message unmarshal(MessageImpl v) throws Exception {
     return v;
   }
}
Am I missing anything here?

Appreciate any help.

Best regards,
Arul



Reply via email to