You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Preethi <pr...@gmail.com> on 2014/04/24 04:47:00 UTC

Failing to load converters

Hi,

 We have a camel routes converts a JSONObject (jettison JSON) to String
using the method convertBodyTo(String.class). However we see that there is
an exception which comes and just fails to continue with the route.
Following is the exception

Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
converter available to convert from type:
org.codehaus.jettison.json.JSONObject to the required type: java.lang.String
with value {"supplyItem_GTIN":"00000000000024".....
[INFO] [talledLocalContainer] 	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:147)
[INFO] [talledLocalContainer] 	at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:100)

This issue occurs intermittenttly. It looks like the camel is unable to load
the default converters.

Thanks,
Preethi



--
View this message in context: http://camel.465427.n5.nabble.com/Failing-to-load-converters-tp5750509.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Failing to load converters

Posted by Preethi <pr...@gmail.com>.
This is something which does not happen always. It happens intermittently.




--
View this message in context: http://camel.465427.n5.nabble.com/Failing-to-load-converters-tp5750509p5750561.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Failing to load converters

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You get this error because there is no type converter in Camel to
convert from that JSONtype your return in that bean to a String.

You need to add such a converter yourself, and convert to string from
a bean or something.
http://camel.apache.org/type-converter.html

On Thu, Apr 24, 2014 at 2:59 PM, Preethi <pr...@gmail.com> wrote:
> Here's how the rote looks like
>
>                 from("direct:runlegacyrules")
>                 .routeId("executeLegacyRules")
>                 .setProperty(SupplyItemRoutesConstants.ORIGINAL_MESSAGE, body())
>                 .setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST))
>                 .setHeader(Exchange.ACCEPT_CONTENT_TYPE,
> constant(SupplyItemRoutesConstants.JSON_CONTENT_TYPE))
>                 .bean(jsonSupplyItemConverter, "convertToSupplyItemLegacyJson")
>                 .convertBodyTo(String.class)
>                 .choice()
>                          //routing to this endpoint will check if V1 Legacy validation toggle is
> turned "on" or "off"
>                         .when(predicate.new
> DivisionPredicate()).to(SupplyItemRoutesConstants.TOGGLE_V1_LEGACY_VALIDATION_ENDPOINT)
>                         //routing to this endpoint will check if V2 Legacy validation toggle is
> turned "on" or "off"
>                         .when(not(predicate.new
> DivisionPredicate())).to(SupplyItemRoutesConstants.TOGGLE_V2_LEGACY_VALIDATION_ENDPOINT)
>                 .end();
>
> The route above takes the message converts to JSON using the converter
> jsonSupplyItemConverter and then converts to to String.class to be passed on
> to the DivisionPredicate.
> The intermittent exception occurs while converting the json to String.class.
> This route is deployed on tomcat.
>
> Thanks,
> Preethi
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Failing-to-load-converters-tp5750509p5750532.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Failing to load converters

Posted by Preethi <pr...@gmail.com>.
Here's how the rote looks like

		from("direct:runlegacyrules")
		.routeId("executeLegacyRules")
		.setProperty(SupplyItemRoutesConstants.ORIGINAL_MESSAGE, body())
		.setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST))
		.setHeader(Exchange.ACCEPT_CONTENT_TYPE,
constant(SupplyItemRoutesConstants.JSON_CONTENT_TYPE))
		.bean(jsonSupplyItemConverter, "convertToSupplyItemLegacyJson")
		.convertBodyTo(String.class)
		.choice()
			 //routing to this endpoint will check if V1 Legacy validation toggle is
turned "on" or "off"
			.when(predicate.new
DivisionPredicate()).to(SupplyItemRoutesConstants.TOGGLE_V1_LEGACY_VALIDATION_ENDPOINT)
			//routing to this endpoint will check if V2 Legacy validation toggle is
turned "on" or "off"
			.when(not(predicate.new
DivisionPredicate())).to(SupplyItemRoutesConstants.TOGGLE_V2_LEGACY_VALIDATION_ENDPOINT) 
		.end();

The route above takes the message converts to JSON using the converter
jsonSupplyItemConverter and then converts to to String.class to be passed on
to the DivisionPredicate.
The intermittent exception occurs while converting the json to String.class. 
This route is deployed on tomcat.

Thanks,
Preethi



--
View this message in context: http://camel.465427.n5.nabble.com/Failing-to-load-converters-tp5750509p5750532.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Failing to load converters

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

Can you tell us more about when did you get this kind of issue?
What’s your camel route look like?
How did deploy the camel route? Did you run it as a stand alone Java Application or deploy it into  some other container?


--  
Willem Jiang

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



On April 24, 2014 at 1:12:01 PM, Preethi (preethi.krishnan14@gmail.com) wrote:
> Hi,
>  
> We have a camel routes converts a JSONObject (jettison JSON) to String
> using the method convertBodyTo(String.class). However we see that there is
> an exception which comes and just fails to continue with the route.
> Following is the exception
>  
> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
> converter available to convert from type:
> org.codehaus.jettison.json.JSONObject to the required type: java.lang.String  
> with value {"supplyItem_GTIN":"00000000000024".....
> [INFO] [talledLocalContainer] at
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:147)  
> [INFO] [talledLocalContainer] at
> org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:100)  
>  
> This issue occurs intermittenttly. It looks like the camel is unable to load
> the default converters.
>  
> Thanks,
> Preethi
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Failing-to-load-converters-tp5750509.html  
> Sent from the Camel - Users mailing list archive at Nabble.com.
>