You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Arul Dhesiaseelan <ar...@fluxcorp.com> on 2008/08/04 19:34:27 UTC

Marshalling Error caused due to ArrayList classcast exception

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




Re: Marshalling Error caused due to ArrayList classcast exception

Posted by Arul Dhesiaseelan <ar...@fluxcorp.com>.
Thanks Dan for your help. Adding asm to the classpath did the trick.

-Arul

Daniel Kulp wrote:
> Do you have an asm-2.x or asm-3.x jar on the classpath?   I think this is one 
> of the use cases where it's completely required.   If so, can I see the 
> complete SEI interface with all the annotations?   You don't have it set 
> to "BARE" mode, do you?
>
> Dan
>
>
> On Monday 04 August 2008 1:34:27 pm Arul Dhesiaseelan wrote:
>   
>> 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(Abs
>> tractOutDatabindingInterceptor.java:113) at
>> org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutIntercep
>> tor.java:68) at
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>> n.java:221) at
>> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingC
>> hainInterceptor.java:74) at
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>> n.java:221) at
>> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationO
>> bserver.java:78) at
>> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(Jet
>> tyHTTPDestination.java:278) at
>> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTT
>> PDestination.java:252) at
>> org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandle
>> r.java:70) at
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
>>     at
>> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCol
>> lection.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
>>     
>
>
>   


Re: Marshalling Error caused due to ArrayList classcast exception

Posted by Daniel Kulp <dk...@apache.org>.
Do you have an asm-2.x or asm-3.x jar on the classpath?   I think this is one 
of the use cases where it's completely required.   If so, can I see the 
complete SEI interface with all the annotations?   You don't have it set 
to "BARE" mode, do you?

Dan


On Monday 04 August 2008 1:34:27 pm Arul Dhesiaseelan wrote:
> 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(Abs
>tractOutDatabindingInterceptor.java:113) at
> org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutIntercep
>tor.java:68) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>n.java:221) at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingC
>hainInterceptor.java:74) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>n.java:221) at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationO
>bserver.java:78) at
> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(Jet
>tyHTTPDestination.java:278) at
> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTT
>PDestination.java:252) at
> org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandle
>r.java:70) at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
>     at
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCol
>lection.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





-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog