Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DBAF0D8D3 for ; Tue, 11 Dec 2012 07:00:05 +0000 (UTC) Received: (qmail 32412 invoked by uid 500); 11 Dec 2012 07:00:05 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 32387 invoked by uid 500); 11 Dec 2012 07:00:05 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 32362 invoked by uid 99); 11 Dec 2012 07:00:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2012 07:00:04 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of willem.jiang@gmail.com designates 209.85.220.45 as permitted sender) Received: from [209.85.220.45] (HELO mail-pa0-f45.google.com) (209.85.220.45) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2012 07:00:00 +0000 Received: by mail-pa0-f45.google.com with SMTP id bg2so2640786pad.32 for ; Mon, 10 Dec 2012 22:59:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:message-id:in-reply-to:references:subject:x-mailer :mime-version:content-type:content-transfer-encoding :content-disposition; bh=HA0DpnGE6CFA1QyW8Fxw8scttFiNy1mmbAmjefjmfaM=; b=eQz5Ign2UrntRr/0b+F7w6btxrSyY6zt1IIYVUz7tPYfJDwAafzrB7k+pDuUXqf4IF lD+PvI8we4H0XuT1O3fHql+8YanjaeOvQJfpICaI6KYXy+4dLGpAlFbiCENUYiarcAxZ 0Ld5RNbgRrJgBThx6FYg+SZzq7QLo9+5+RZA9Gycw12+2+jq1Ojzxp6BcYDvKRStT4LZ lot+gQzvy0oHZA5r9HvtGIjaYJbPVErbAmTvbtz+zuHoORNLJDzAASG2Lxux/bBPEUOC 1bXuZwLm0WpT/wh7Euvvi22qUO8yVexFKh7f8Wq0C+jPgPC+5+MxMCvGICUOpblUraGN oZ6w== Received: by 10.68.197.68 with SMTP id is4mr45545324pbc.30.1355209179687; Mon, 10 Dec 2012 22:59:39 -0800 (PST) Received: from [192.168.1.135] ([123.116.42.109]) by mx.google.com with ESMTPS id ty4sm13240918pbc.57.2012.12.10.22.59.36 (version=SSLv3 cipher=OTHER); Mon, 10 Dec 2012 22:59:38 -0800 (PST) Date: Tue, 11 Dec 2012 14:59:33 +0800 From: Willem jiang To: users@camel.apache.org Message-ID: <144B1BB72F5A426083DA187BECDE79E1@gmail.com> In-Reply-To: <1355205786535-5723880.post@n5.nabble.com> References: <1355205786535-5723880.post@n5.nabble.com> Subject: Re: NoTypeConversionAvailableException : When using interface as Apache Camel Proxy X-Mailer: sparrow 1.6.4 (build 1176) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org What's the appUtil.extractResponse looks like=3F Did you try to converter the message body into ServiceProviderRequest=3F -- =20 Willem Jiang Red Hat, Inc. =46useSource is now part of Red Hat Web: http://www.fusesource.com =7C 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 =20 Weibo: =E5=A7=9C=E5=AE=81willem On Tuesday, December 11, 2012 at 2:03 PM, anand=5Ftech wrote: > I have an interface which I am using as Camel Proxy > . My route is as below:= > =20 > from(=22direct:services=22) > .onException(Exception.class) > .process(new Processor() =7B > =40Override > public void process(Exchange arg0) throws Exception =7B > Exception e =3D arg0.getProperty(Exchange.EXCEPTION=5FCAUGHT, > Exception.class); > LOGGER.error(e, e.getMessage()); > =7D > =7D).handled(true).end() > .setHeader(Exchange.HTTP=5FURI, simple(=22=24=7Bbody.url=7D=22)) > .setHeader(Exchange.HTTP=5FMETHOD,simple(=22=24=7Bbody.httpMethod=7D=22= )) > .setHeader(Exchange.CONTENT=5FTYPE, simple(=22=24=7Bbody.contentType=7D= =22)) > .setBody(simple(=22=24=7Bbody.requestBody=7D=22)) > .choice() > .when(simple(=22=24=7Bbody.proxyRequired=7D =3D=3D 'true'=22)) > .inOut(=22=7B=7Bhttp.urlProxy=7D=7D=22) > .otherwise() > .inOut(=22=7B=7Bhttp.url=7D=7D=22) > .end() > .setBody(bean(appUtil, =22extractResponse=22)); > =20 > =20 > The interface is : =20 > =20 > public interface ApiServices =7B > =20 > ServiceProviderResponse performOperation(ServiceProviderRequest > request); > =20 > =7D > =20 > And the ServiceProviderResponse and ServiceProviderRequest classes : =20 > =20 > public class ServiceProviderRequest =7B > =20 > private String url; > private String requestBody; > private String httpMethod; > private String contentType; > private boolean proxyRequired; > private Map headers; > =20 > //getters and setters > =20 > =7D > =20 > public class ServiceProviderResponse =7B > =20 > private int statusCode; > private String body; > private String errorMessage; > private String contentType; > private String url; > =20 > //getters and setters > =7D > =20 > This is how this whole thing is working : =20 > =20 > =40Produce(uri =3D =22direct:services=22) > ApiServices appServices; > =20 > ServiceProviderResponse response =3D =20 > appServices.performOperation(request); > =20 > Earlier my interface's method was : =60ServiceProviderResponse > performOperation(String url);=60 and it worked fine(ofcourse my route w= as > different earlier). So is it something that we cannot use custom object= > types like this=3F The exception that I get : =20 > =20 > Caused by: org.apache.camel.InvalidPayloadException: No body available > of type: com.common.util.ServiceProviderResponse but has value: > BeanInvocation public abstract com.common.util.ServiceProviderResponse > com.common.util.ApiServices.performOperation(com.common.util.ServicePro= viderRequest) > with =5Bcom.common.util.ServiceProviderRequest=404ce55b=5D=5D of type: > org.apache.camel.component.bean.BeanInvocation on: Message: BeanInvocat= ion > public abstract com.common.util.ServiceProviderResponse > com.common.util.ApiServices.performOperation(com.common.util.ServicePro= viderRequest) > with =5Bcom.common.util.ServiceProviderRequest=404ce55b=5D=5D. Caused b= y: No type > converter available to convert from type: > org.apache.camel.component.bean.BeanInvocation to the required type: > com.common.util.ServiceProviderResponse with value BeanInvocation publi= c > abstract com.common.util.ServiceProviderResponse > com.common.util.ApiServices.performOperation(com.common.util.ServicePro= viderRequest) > with =5Bcom.common.util.ServiceProviderRequest=404ce55b=5D=5D. Exchange= =5BMessage: > BeanInvocation public abstract com.common.util.ServiceProviderResponse > com.common.util.ApiServices.performOperation(com.common.util.ServicePro= viderRequest) > with =5Bcom.common.util.ServiceProviderRequest=404ce55b=5D=5D=5D. Cause= d by: > =5Borg.apache.camel.NoTypeConversionAvailableException - No type conver= ter > available to convert from type: > org.apache.camel.component.bean.BeanInvocation to the required type: > com.common.util.ServiceProviderResponse with value BeanInvocation publi= c > abstract com.common.util.ServiceProviderResponse > com.common.util.ApiServices.performOperation(com.common.util.ServicePro= viderRequest) > with =5Bcom.common.util.ServiceProviderRequest=404ce55b=5D=5D=5D > at > org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.ja= va:102) > at > org.apache.camel.component.bean.AbstractCamelInvocationHandler.getBody(= AbstractCamelInvocationHandler.java:58) > at > org.apache.camel.component.bean.AbstractCamelInvocationHandler.afterInv= oke(AbstractCamelInvocationHandler.java:148) > at > org.apache.camel.component.bean.AbstractCamelInvocationHandler=241.call= (AbstractCamelInvocationHandler.java:85) > at java.util.concurrent.=46utureTask=24Sync.innerRun(Unknown Source) > at java.util.concurrent.=46utureTask.run(Unknown Source) > at > org.apache.camel.component.bean.AbstractCamelInvocationHandler.invokeWi= thbody(AbstractCamelInvocationHandler.java:101) > at > org.apache.camel.component.bean.CamelInvocationHandler.invoke(CamelInvo= cationHandler.java:44) > ... 43 more > Caused by: org.apache.camel.NoTypeConversionAvailableException: No type= > converter available to convert from type: > org.apache.camel.component.bean.BeanInvocation to the required type: > com.common.util.ServiceProviderResponse with value BeanInvocation publi= c > abstract com.common.util.ServiceProviderResponse > com.common.util.ApiServices.performOperation(com.common.util.ServicePro= viderRequest) > with =5Bcom.common.util.ServiceProviderRequest=404ce55b=5D=5D > at > org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConv= ertTo(BaseTypeConverterRegistry.java:147) > at > org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.ja= va:100) > ... 50 more > =20 > Exception says something about TypeConverters, do I need to implement a= type > converter also now =3F If yes how to do it=3F I have already gone throu= gh Camel > docs for type converter but I dont understand from it much. > Also I guess most of you have understood what I want to achieve, so if = you > guys have any different methods to accomplish this or some suggestions,= > please post it. > =20 > =20 > =20 > =20 > =20 > =20 > =20 > -- > View this message in context: http://camel.465427.n5.nabble.com/NoTypeC= onversionAvailableException-When-using-interface-as-Apache-Camel-Proxy-tp= 5723880.html > Sent from the Camel - Users mailing list archive at Nabble.com (http://= Nabble.com).