camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clarkcb <clar...@gmail.com>
Subject How can I have a byte[] return value from a camel CXF endpoint?
Date Fri, 07 Dec 2012 02:23:37 GMT
Hello,

I've created a Camel CXF endpoint that receives an ArrayList of
[java.io.File, byte[]] representing the File object and the file's contents,
respectively. Here's the service endpoint method definition:

public byte[] convertFile(File inputFile, byte[] inputArray)

Here's my test route in Spring:

<route>
  <from uri="cxf:bean:myFileConverterEndPoint" />
  <process ref="testProcessor"/>
  <to uri="mock:end"/>
</route>

testProcessor's process method does the conversion and sets the body of the
in message:

exchange.getIn().setBody(resultBytes, byte[].class)


... and here's my test code:

List params = new java.util.ArrayList();
params.add(testFile);
params.add(FileHelper.toByteArray(testFile));

Map headerMap = new HashMap<String,Object>();
headerMap.put("fileName", testFile.getName());

byte[] reply =
template.requestBodyAndHeaders("cxf:bean:myFileConverterEndPoint", params,
headerMap);

Here's the exception stack trace I get:

java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object;
	at
org.apache.camel.component.cxf.DefaultCxfBinding.populateCxfResponseFromExchange(DefaultCxfBinding.java:344)[camel-cxf-2.10.x-fuse-SNAPSHOT.jar:2.10.x-fuse-SNAPSHOT]
	at
org.apache.camel.component.cxf.CxfConsumer$1.setResponseBack(CxfConsumer.java:180)[camel-cxf-2.10.x-fuse-SNAPSHOT.jar:2.10.x-fuse-SNAPSHOT]
	at
org.apache.camel.component.cxf.CxfConsumer$1.asyncInvoke(CxfConsumer.java:107)[camel-cxf-2.10.x-fuse-SNAPSHOT.jar:2.10.x-fuse-SNAPSHOT]
	at
org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:72)[camel-cxf-2.10.x-fuse-SNAPSHOT.jar:2.10.x-fuse-SNAPSHOT]
	at
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)[cxf-api-2.6.1.jar:2.6.1]
	at
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)[cxf-api-2.6.1.jar:2.6.1]
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)[cxf-api-2.6.1.jar:2.6.1]
	at
org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:231)[cxf-api-2.6.1.jar:2.6.1]
	at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:79)[cxf-api-2.6.1.jar:2.6.1]
	at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:344)[cxf-rt-transports-http-jetty-2.6.1.jar:2.6.1]
	at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:310)[cxf-rt-transports-http-jetty-2.6.1.jar:2.6.1]
	at
org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)[cxf-rt-transports-http-jetty-2.6.1.jar:2.6.1]
	at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:943)[jetty-server-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:879)[jetty-server-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)[jetty-server-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:188)[jetty-server-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)[jetty-server-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.server.Server.handleAsync(Server.java:394)[jetty-server-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:446)[jetty-server-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:936)[jetty-server-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:893)[jetty-http-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:224)[jetty-http-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)[jetty-server-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)[jetty-io-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)[jetty-io-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)[jetty-util-7.5.4.v20111024.jar:7.5.4.v20111024]
	at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)[jetty-util-7.5.4.v20111024.jar:7.5.4.v20111024]
	at java.lang.Thread.run(Thread.java:680)[:1.6.0_37]

By the way, I should probably mention that I'm actually using scala, but
I've converted the code to java, so if there are any quirks in the code it's
probably a result of bad conversion on my part.




--
View this message in context: http://camel.465427.n5.nabble.com/How-can-I-have-a-byte-return-value-from-a-camel-CXF-endpoint-tp5723742.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message