What version of Camel are you using? The exception is not caught by Camel's exception-handling facilities because they only apply during the processing of the exchange. So there are small windows where exceptions can handle on consumers (like the JMS consumer) and these will be handled component specific. From the Camel in Action book p124:
"So what happens if the file consumer can’t read the file? The answer is component- specific, and each Camel component must deal with this in its own way. Some compo- nents will ignore and skip the message, others will retry a number of times, and others will gracefully recover." Looks like in your case specifically, there was an exception that happened in normal exchange processing, but in trying to "wrap the exception" another exception occurred... not sure why. are the rest of your messages processed correctly? Even when you get the exception, did your route complete? ie... was the call made to the web service? On Tue, Dec 3, 2013 at 10:55 AM, MichaelAtSAG <mebevilac...@gmail.com> wrote: > Hello, > > This application connects to JMS and routes the message to a websocket > endpoint. Every 15th message or so, the following exception is raised: > > Exception: > > [Camel (TwitterApp1) thread #1 - > JmsConsumer[Event::WebM::Communication::Twitter::1.1::TweetReceived]] > EndpointMessageListener WARN Execution of JMS message > listener failed. Caused by: [org.apache.camel.RuntimeCamelException - > java.lang.ArrayIndexOutOfBoundsException] > org.apache.camel.RuntimeCamelException: > java.lang.ArrayIndexOutOfBoundsException > at > org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1344) > at > org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:186) > at > org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:107) > at > org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:562) > at > org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:500) > at > org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468) > at > org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325) > at > org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263) > at > org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1096) > at > org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1088) > at > org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:985) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) > at java.lang.Thread.run(Thread.java:722) > Caused by: java.lang.ArrayIndexOutOfBoundsException > > > Route: > > <beans profile="TwitterApp"> > <camelContext id="TwitterApp1" > xmlns="http://camel.apache.org/schema/spring" autoStartup="true"> > > <propertyPlaceholder id="twitterProperties" > location="twitterApp.properties" /> > > <endpoint id="webappWebsocketNERVEndpointOut" > uri="websocket://{{wsHost}}:{{wsPort}}/nerv-tweet-fromJMS?staticResources=classpath:.&sendToAll=true" > /> > > > <endpoint id="twitterProducer" > > uri="twitter://timeline/user?consumerKey={{consumerKey}}&consumerSecret={{consumerSecret}}&accessToken={{accessToken}}&accessTokenSecret={{accessTokenSecret}}" > /> > > <onException> > > <exception>org.apache.camel.RuntimeCamelException</exception> > > <exception>java.lang.ArrayIndexOutOfBoundsException</exception> > <handled> > <constant>true</constant> > </handled> > <to id="streamOut" uri="stream:out" /> > <transform> > <simple>In exception loop!</simple> > </transform> > <to id="streamOutSimple" uri="stream:out" /> > </onException> > > <route id="TweetReceivedFromJMS"> > > <from id="NERVJMS1" > uri="nervJMS1:topic:Event::WebM::Communication::Twitter::1.1::TweetReceived" > /> > > > <transform> > <simple>JMS Channel processing tweet event from > @${header.Status$User$ScreenName} at ${header.$Event$Start}</simple> > </transform> > > <to uri="webappWebsocketNERVEndpointOut" /> > </route> > > </camelContext> > > NERVJMS1 bean: > > > <?xml version="1.0" encoding="UTF-8"?> > <beans xmlns="http://www.springframework.org/schema/beans" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans.xsd > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring.xsd"> > > <beans profile="suite-wide"> > > <bean id="nervJMS1" > class="org.apache.camel.component.jms.JmsComponent"> > <property name="connectionFactory" ref="cachedConnectionFactory" > /> > <property name="destinationResolver" > ref="defaultDestinationResolver" /> > </bean> > > <bean id="cachedConnectionFactory" > class="org.springframework.jms.connection.CachingConnectionFactory"> > <property name="targetConnectionFactory" > ref="jndiObjectFactoryBean" /> > <property name="sessionCacheSize" value="2000" /> > <property name="cacheProducers" value="false" /> > </bean> > > <bean id="jndiObjectFactoryBean" > class="org.springframework.jndi.JndiObjectFactoryBean" > depends-on="defaultDestinationResolver"> > <property name="jndiTemplate" ref="jndiTemplateNirvana" /> > <property name="jndiName" ref="eventFactory" /> > </bean> > > <bean id="defaultDestinationResolver" > class="com.softwareag.eda.jndi.NervResolver" > depends-on="jndiTemplateNirvana" init-method="init"> > <property name="jndiTemplate" ref="jndiTemplateNirvana" /> > <property name="classLoader"> > <null /> > </property> > </bean> > > <bean id="jndiTemplateNirvana" > class="org.springframework.jndi.JndiTemplate"> > <property name="environment"> > <map> > <entry key="java.naming.factory.initial" > value="com.pcbsys.nirvana.nSpace.NirvanaContextFactory" /> > <entry key="java.naming.provider.url" > value="nsp://localhost:9000" /> > <entry key="connectionFactory" value-ref="eventFactory" > /> > </map> > </property> > </bean> > > <bean id="eventFactory" class="java.lang.String"> > <constructor-arg value="EventFactory" /> > </bean> > > </beans> > > </beans> > > Two questions: > > 1. How to prevent the exception from happening? > 2. Why does the exception handler not capture the exception? > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/java-lang-ArrayIndexOutOfBoundsException-when-receiving-from-JMS-tp5744262.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Christian Posta http://www.christianposta.com/blog twitter: @christianposta