camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sanjbh <san...@gmail.com>
Subject Getting ClassCastException in Camel route while handling response containing java.util.List
Date Wed, 01 Jan 2014 12:09:47 GMT
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<Book> getBooks();

The CXF endpoint is defined as:

<cxf:cxfEndpoint id="bookService" 
                 address="http://localhost:9045/bookservice" 
                 serviceClass="org.test.cxfws.service.BookDBService">        
</cxf:cxfEndpoint>

The operation queries a list of books and returns it to the caller. The
Camel route looks like this:
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="cxf:bean:bookService"/>
        <choice>                
            <when>                    
                <simple>${header.operationName} == 'getBooks'</simple>       
            
                <to uri="bean:wsImplBean?method=getBooks"/>
            </when>
            <to uri="log:outboundSoapResponse"/>
         <choice>
     </route>
</camel:camelContext>

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