[ 
https://issues.apache.org/jira/browse/CAMEL-7151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13890561#comment-13890561
 ] 

Marios Trivizas edited comment on CAMEL-7151 at 2/4/14 10:57 AM:
-----------------------------------------------------------------

The issue is not valid as In my code I'm missing the call to start the 
SjmsComponent. Since the CamelContext is already started it doesn't start the 
SjmsComponent automatically and that is the root cause of the error. So the 
problem is fixed by adding the call to start() method on SjmsComponent:
{code}
SjmsComponent sjms = new SjmsComponent();
sjms.setConnectionFactory(dstConnectionFactory);
camelContext.addComponent(dstEndpoint.getName(), sjms);
sjms.start(); // missing call
{code}


was (Author: matriv):
The issue is not valid as In my code I'm missing the call to start the 
SjmsComponent. Since the CamelContext is already started it doesn't start the 
SjmsComponent automatically and that is the root cause of the error. So the 
problem is fixed by adding the call to start() method on SjmsComponent:
{code}
SjmsComponent sjms = new SjmsComponent();
sjms.setConnectionFactory(dstConnectionFactory);
camelContext.addComponent(dstEndpoint.getName(), sjms);
*sjms.start();*
{code}

> camel-sjms NullPointerException when adding new route with Sjms as producer.
> ----------------------------------------------------------------------------
>
>                 Key: CAMEL-7151
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7151
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 2.13.0
>            Reporter: Marios Trivizas
>            Assignee: Scott England-Sullivan
>
> The following exception is thrown when adding new route programmatically with 
> Sjms as producer:
> java.lang.NullPointerException
>       at 
> java.util.concurrent.ArrayBlockingQueue.checkNotNull(ArrayBlockingQueue.java:145)
>       at 
> java.util.concurrent.ArrayBlockingQueue.offer(ArrayBlockingQueue.java:296)
>       at java.util.AbstractQueue.add(AbstractQueue.java:95)
>       at 
> java.util.concurrent.ArrayBlockingQueue.add(ArrayBlockingQueue.java:283)
>       at 
> org.apache.camel.component.sjms.jms.ObjectPool.fillPool(ObjectPool.java:55)
>       at 
> org.apache.camel.component.sjms.SjmsProducer.doStart(SjmsProducer.java:139)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:407)
>       at 
> org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:123)
>       at 
> org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:191)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1154)
>       at 
> org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:41)
>       at 
> org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:28)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:155)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:984)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79)
>       at 
> org.apache.camel.processor.FilterProcessor.doStart(FilterProcessor.java:80)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.ChoiceProcessor.doStart(ChoiceProcessor.java:171)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1154)
>       at 
> org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:41)
>       at 
> org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:28)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:155)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:984)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79)
>       at 
> org.apache.camel.processor.FilterProcessor.doStart(FilterProcessor.java:80)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1154)
>       at 
> org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:41)
>       at 
> org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:28)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:155)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103)
>       at 
> org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89)
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79)
>       at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>       at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74)
>       at 
> org.apache.camel.impl.RouteService.startChildService(RouteService.java:329)
>       at org.apache.camel.impl.RouteService.warmUp(RouteService.java:158)
>       at 
> org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2109)
>       at 
> org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2039)
>       at 
> org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2061)
>       at 
> org.apache.camel.impl.DefaultCamelContext.startRouteService(DefaultCamelContext.java:1938)
>       at 
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:772)
>       at 
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1914)
>       at 
> org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:707)
>       at 
> org.apache.camel.builder.RouteBuilder.populateRoutes(RouteBuilder.java:337)
>       at 
> org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:264)
>       at 
> org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:669)
>       at 
> de.groupon.jms.DynamicRoutesManager.addRoute(DynamicRoutesManager.java:178)
> Here is my code:
> {code}
> public static RouteBuilder buildRoute(final DynamicRoute route, final 
> CamelContext camelContext, final boolean autoStartup) throws Exception {
>               InitialContext ic = 
> getInitialContext(route.getSourceEndpoint().getHost(), 
> route.getSourceEndpoint().getJndiPort());
>               ConnectionFactory srcConnectionFactory = 
> (ConnectionFactory)ic.lookup("/connectionFactory/local/" + 
> route.getSourceEndpoint().getJndiConnectionFactoryName());
>               
> ((HornetQJMSConnectionFactory)srcConnectionFactory).setReconnectAttempts(-1);
>               
> ((HornetQJMSConnectionFactory)srcConnectionFactory).setRetryInterval(1000);
>               
> ((HornetQJMSConnectionFactory)srcConnectionFactory).setConnectionTTL(120000);
>               
> ((HornetQJMSConnectionFactory)srcConnectionFactory).setClientFailureCheckPeriod(2000);
>               
> ((HornetQJMSConnectionFactory)srcConnectionFactory).setCallTimeout(60000);
>               
> ((HornetQJMSConnectionFactory)srcConnectionFactory).setConsumerWindowSize(4194304);
>               
> ((HornetQJMSConnectionFactory)srcConnectionFactory).setInitialConnectAttempts(-1);
>               
> ((HornetQJMSConnectionFactory)srcConnectionFactory).setUseGlobalPools(false);
>               
> ((HornetQJMSConnectionFactory)srcConnectionFactory).setScheduledThreadPoolMaxSize(5);
>               
> ((HornetQJMSConnectionFactory)srcConnectionFactory).setThreadPoolMaxSize(5);
>               camelContext.addComponent(route.getSourceEndpoint().getName(), 
> JmsComponent.jmsComponentAutoAcknowledge(srcConnectionFactory));
>               ic.close();
>               RouteBuilder newRouteBuilder;
>               JmsEndpoint dstEndpoint = (JmsEndpoint) 
> route.getDestinationEndpoint();
>               ic = getInitialContext(dstEndpoint.getHost(), 
> dstEndpoint.getJndiPort());
>               ConnectionFactory dstConnectionFactory = 
> (ConnectionFactory)ic.lookup("/connectionFactory/local/" + 
> dstEndpoint.getJndiConnectionFactoryName());
>               
> ((HornetQJMSConnectionFactory)dstConnectionFactory).setReconnectAttempts(-1);
>               
> ((HornetQJMSConnectionFactory)dstConnectionFactory).setRetryInterval(1000);
>               
> ((HornetQJMSConnectionFactory)dstConnectionFactory).setConnectionTTL(120000);
>               
> ((HornetQJMSConnectionFactory)dstConnectionFactory).setClientFailureCheckPeriod(2000);
>               
> ((HornetQJMSConnectionFactory)dstConnectionFactory).setCallTimeout(60000);
>               
> ((HornetQJMSConnectionFactory)dstConnectionFactory).setConsumerWindowSize(4194304);
>               
> ((HornetQJMSConnectionFactory)dstConnectionFactory).setInitialConnectAttempts(-1);
>               
> ((HornetQJMSConnectionFactory)dstConnectionFactory).setUseGlobalPools(false);
>               
> ((HornetQJMSConnectionFactory)dstConnectionFactory).setScheduledThreadPoolMaxSize(5);
>               
> ((HornetQJMSConnectionFactory)dstConnectionFactory).setThreadPoolMaxSize(5);
>               SjmsComponent sjms = new SjmsComponent();
>               sjms.setConnectionFactory(dstConnectionFactory);
>               camelContext.addComponent(dstEndpoint.getName(), sjms);
>               ic.close();
>               newRouteBuilder = new RouteBuilder() {
>                       @Override
>                       public void configure() {
>                               
> errorHandler(deadLetterChannel("log:de.groupon.jms.route.deadletter." + 
> route.getName() + 
> "?level=ERROR&showBody=true&showHeaders=true&showExchangePattern=false&showBodyType=false").maximumRedeliveries(3).redeliveryDelay(500)
>                                               
> .retryAttemptedLogLevel(LoggingLevel.WARN).retriesExhaustedLogLevel(LoggingLevel.ERROR)
>                                               
> .log("de.groupon.jms.route.error." + route.getName()));
>                               
> from(route.getSourceEndpoint().getCamelUri()).routeId(route.getName()).autoStartup(autoStartup)
>                                       
> .filter().method(route.getFilterChain(), "filterMessage")
>                                       .process(route.getTransformer())
>                                       .choice().when(body().isNotNull())
>                                               .to(ExchangePattern.InOnly, 
> route.getDestinationEndpoint().getCamelUri())
>                                               .to("log:de.groupon.jms.route." 
> + route.getName() + 
> "?level=INFO&showBody=true&showHeaders=true&showExchangePattern=false&showBodyType=false")
>                                               .stop()
>                                       .otherwise()
>                                               .stop();
>                       }
>               };
>       }
>       return newRouteBuilder;
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to