camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Getting ClassCastException in Camel route while handling response containing java.util.List
Date Thu, 02 Jan 2014 11:49:19 GMT
You need to put the Book List into another List, as camel-cxf use list to hold the response
for handling the InOut parameters.


--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com(http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com(http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On January 1, 2014 at 8:10:26 PM, sanjbh (sanjbh@gmail.com) wrote:
>  
> I have a Camel route exposed as a CXF web service. This is a bottom  
> up web
> service and has an operation like so:
>  
> List getBooks();
>  
> The CXF endpoint is defined as:
>  
> > address="http://localhost:9045/bookservice"
> serviceClass="org.test.cxfws.service.BookDBService">  
>  
>  
> The operation queries a list of books and returns it to the caller.  
> The
> Camel route looks like this:
>  
>  
>  
>  
>  
> ${header.operationName} == 'getBooks'  
>  
>  
>  
>  
>  
>  
>  
> After running the route, I am getting the following exception:  
>  
> *org.apache.cxf.interceptor.Fault: org.test.cxfws.service.Book  
> cannot be
> cast to java.util.List *at
> org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:117)
 
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
 
> at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
 
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
 
> ...
>  
> *Caused by: java.lang.ClassCastException: org.test.cxfws.service.Book  
> cannot
> be cast to java.util.List at
> *org.test.cxfws.service.GetBooksResponse_WrapperTypeHelper1.createWrapperObject(Unknown
 
> Source) at
> org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:101)
 
>  
> I can see that the getBooks method from the bean wsImpBean is executed  
> and
> the result being returned at the end of the choice block inside  
> the route:
>  
> [ qtp1653072092-14] outboundSoapResponse INFO Exchange[ExchangePattern:  
> InOut, BodyType: java.util.ArrayList, Body:
> [org.test.cxfws.service.Book@63f1858b, org.test.cxfws.service.Book@5769bf0,  
> org.test.cxfws.service.Book@2df7ac5d, org.test.cxfws.service.Book@5f55253e,  
> org.test.cxfws.service.Book@4f003a57]]
>  
> Can someone help me to understand why the ClassCastException.  
>  
> Thanks.
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Getting-ClassCastException-in-Camel-route-while-handling-response-containing-java-util-List-tp5745393.html
 
> Sent from the Camel - Users mailing list archive at Nabble.com.  
>  


Mime
View raw message