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: Problem creating seda endpoint with queue size
Date Fri, 20 Aug 2010 08:49:28 GMT
It's not easy to make Camel work with all OSGi platform rightly.
I just went through the Camel OSGi related code, it uses another method 
to load converter class, and it should be fine.

I don't know how you inject the camel context, if this camel context is 
not replace its DefaultPackageScanClassResolver to 
OSGiPackageScanClassResolver, you may hit this kind of issue.

Can you create a JIRA a submit your test case with it?
So I can dig the code to see if it is resolved in Camel trunk.

Willem

ariekenb wrote:
> I'm running FUSE ESB 4.2.0-fuse-01-00 with it's default version of Camel 2.2. 
> I'm trying to do something simple: I have a camel context defined in a
> spring file:
> 
> 	<camel:camelContext
> 		id="aaron-test">
> 	</camel:camelContext>
> 
> I inject it into a bean implementing CamelContextAware and try to do this:
> 
> 			camelContext.addComponent("activemq", ActiveMQComponent
> 					.activeMQComponent("tcp://localhost:61616"));
> 
> 			camelContext.addRoutes(new RouteBuilder() {
> 
> 				public void configure() throws Exception {
> 					from("activemq:queue:test.queue").to(
> 							"vm:eventMessageEndpoint?size=220000");
> 				}
> 
> 			});
> 
> Often (but not always) I get this exception:
> 
>  Failed to resolve endpoint: vm://eventMessageEndpoint?size=220000 due to:
> null
>         at
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:446)
>         at
> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:46)
>         at
> org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:158)
>         at
> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:113)
>         at
> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:119)
>         at
> org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:63)
>         at
> org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:57)
>         at
> org.apache.camel.model.ToDefinition.createProcessor(ToDefinition.java:87)
>         at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:325)
>         at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:137)
>         at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:690)
>         ... 22 more
> Caused by: java.lang.NullPointerException
>         at
> org.apache.camel.component.seda.SedaComponent.createQueue(SedaComponent.java:46)
>         at
> org.apache.camel.component.vm.VmComponent.getBlockingQueue(VmComponent.java:53)
>         at
> org.apache.camel.component.vm.VmComponent.createEndpoint(VmComponent.java:43)
>         at
> org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:80)
>         at
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:425)
>         ... 32 more
> 
> 
> 
> So SedaComponent.createQueue is throwing NPE.  This happens because
> getAndRemoveParameter() is returning null for the size parameter, which
> happens because CamelContextHelper.convertTo() returns null.
> 
> Why does this happen - it seems to be because DefaultTypeConverter does not
> have any type converters registered on it.  This means it is not able to
> convert the string parameter "220000" to an Integer.  This is due to these
> earlier exceptions when the camel context was created:
> 
> 16:41:07,220 | DEBUG | ExtenderThread-6 | DefaultPackageScanClassResolver  |
> .DefaultPackageScanClassResolver  280 | Cannot read entries in url:
> bundleresource://50.fwk1545595021/org/apache/camel/converter/
> java.net.MalformedURLException: no protocol: /org/apache/camel/converter/
>         at java.net.URL.<init>(URL.java:567)
>         at java.net.URL.<init>(URL.java:464)
>         at java.net.URL.<init>(URL.java:413)
>         at
> org.apache.camel.impl.DefaultPackageScanClassResolver.find(DefaultPackageScanClassResolver.java:264)
>         at
> org.apache.camel.impl.DefaultPackageScanClassResolver.find(DefaultPackageScanClassResolver.java:180)
>         at
> org.apache.camel.impl.DefaultPackageScanClassResolver.findAnnotated(DefaultPackageScanClassResolver.java:100)
>         at
> org.apache.camel.impl.converter.AnnotationTypeConverterLoader.load(AnnotationTypeConverterLoader.java:63)
>         at
> org.apache.camel.impl.converter.DefaultTypeConverter.loadTypeConverters(DefaultTypeConverter.java:361)
>         at
> org.apache.camel.impl.converter.DefaultTypeConverter.doStart(DefaultTypeConverter.java:384)
>         at
> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:53)
>         at
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:49)
>         at
> org.apache.camel.impl.DefaultCamelContext.startServices(DefaultCamelContext.java:1174)
> 
> This looks like this bug
> (https://issues.apache.org/activemq/browse/CAMEL-2663), which resulted in
> the camel-eclipse class resolver being written in camel 2.3 (not available
> to me in camel 2.2).  
> 
> I have found an ugly workaround, which is to manually force a String to
> Integer type converter to be registered on the camel context:
> 
> 			((DefaultTypeConverter) camelContext.getTypeConverter())
> 					.addTypeConverter(Integer.class, String.class,
> 							new StaticMethodTypeConverter(ObjectConverter.class
> 									.getMethod("toInteger", Object.class)));
> 
> 
> What is the correct fix for this?  Is it necessary to use the new
> camel-eclipse class resolver with FUSE ESB?


Mime
View raw message