DefaultShutdownStrategy not working in apache camel - apache-camel

I have created a bean of DefaultShutdownStrategy in camel-context.xml file and was expecting that it will shutdown the routes gracefully. However, I am not seeing any DefaultShutdownStrategy related logging happening during shutdown of my apache camel application.
Last logs I could see is:
2022-12-05 02:43:49,424 DEBUG org.apache.camel.main.DefaultMainShutdownStrategy:75 - Received hangup signal, stopping the main instance.
Now I am not sure if DefaultShutdownStrategy is working or not for graceful shutdown of context.
I have enabled DEBUG log also for "org.apache.camel.impl" package in my log4j.xml
Can someone please help me in figuring out why my DefaultShutdownStrategy is not working ?
I tried creating bean of DefaultShutdownStrategy
Below is the bean definition of DefaultShutdownStrategy in my camel-context.xml
<bean id="fixShutdownStrategy" class="org.apache.camel.impl.engine.DefaultShutdownStrategy">
<constructor-arg name="camelContext" ref="camel"/>
<property name="timeout" value="240"/>


Camel + Tomcat + Datasource + JNDI = Impossible

I have a Spring app that runs in Tomcat and connects okay to a JNDI configured datasource. I'm trying to get my Apache Camel app to do the same.
Tomcat context.xml
<ResourceLink global="jdbc/deapplication-datasource" name="jdbc/deapplication-datasource" type="javax.sql.DataSource"/>
Tomcat server.xml
<Resource name="jdbc/deapplication-datasource"
maxTotal="50" maxIdle="30" maxWaitMillis="10000"
username="yada" password="nada"
<!-- JNDI connection fails with Tomcat localhost (works in our testing/WebLogic environment -->
<bean id="dataSourceHello" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/deapplication-datasource"/>
<!-- manual config works
<bean id="dataSourceHello" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:#//test-cluster:1521/" />
<property name="username" value="yada" />
<property name="password" value="nada" />
Java/Camel code:
.setBody(simple("select * from dual"))
Tomcat log:
2022-06-13 12:07:49,879 INFO - 0
2022-06-13 12:07:49,881 INFO - 1
2022-06-13 12:07:50,444 ERROR - Failed delivery for (MessageId: ID-IT-DEV-VM-112-1655147269874-0-1 on ExchangeId: ID-IT-DEV-VM-112-1655147269874-0-1). On delivery attempt: 0 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-IT-DEV-VM-112-1655147269874-0-1]
2022-06-13 12:07:50,456 ERROR - null org.apache.camel.CamelExecutionException Exception occurred during execution on the exchange: Exchange[ID-IT-DEV-VM-112-1655147269874-0-1]
Tomcat and the app start up okay, but when I hit the restful path to test healthCheckDb it fails after log 1 but before log 2 (as you probably noticed above). The same statement works if I use the manual configured datasource. But I'd prefer to use the same setup as we use for WebLogic so I don't have to keep uncommenting and commenting the camel-config.xml file.
(Side note: after hours of research, have not seen 2 web pages agree on how to configure Tomcat JNDI for a datasource).
Possible to get Camel working with JNDI?

Camel Zookeeper Component not found in activeMQs embedded Camel Modul

On 3 virtual machines running Zookeeper + ActiveMQ.
ActiveMQ Version 5.15.9 with Camel Version 2.19.5
Now, I'm using the embedded Camel EIP Framework in ActiveMQ.
I want to get a specific node from Zookeeper based on an event.
<camelContext id="camel" xmlns="">
<!-- You can use Spring XML syntax to define the routes here using the <route> element -->
<description>Read zookeeper variant 1</description>
<from uri="activemq:example.zoo1"/>
<to uri="activemq:example.zooRead1"/>
<description>Read zookeeper variant 2</description>
<from uri="activemq:example.zoo2"/>
<to uri="activemq:example.zooRead2"/>
In the Log File following exception occured with variant 1
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: zookeeper://localhost:2182/some/node/99 due to: No component found with scheme: zookeeper
at org.apache.camel.impl.DefaultCamelContext.getEndpoint([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.util.ExchangeHelper.resolveEndpoint([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.PollEnricher.resolveEndpoint([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.PollEnricher.process([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.RedeliveryErrorHandler.process([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.CamelInternalProcessor.process([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.Pipeline.process([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.Pipeline.process([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.CamelInternalProcessor.process([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.processor.DelegateAsyncProcessor.process([camel-core-2.19.5.jar:2.19.5]
at org.apache.camel.component.jms.EndpointMessageListener.onMessage([camel-jms-2.19.5.jar:2.19.5]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener([spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener([spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener([spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute([spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute([spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener([spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop([spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$[spring-jms-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at java.util.concurrent.ThreadPoolExecutor.runWorker([:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$[:1.8.0_222]
2019-10-01 15:06:05,652 | DEBUG | Message exchange has failed: so breaking out of pipeline for exchange: Exchange[ID-Monkey-34387-1569942241018-0-1] Exception: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: zookeeper://localhost:2182/some/node/99 due to: No component found with scheme: zookeeper | org.apache.camel.processor.Pipeline | Camel (camel) thread #1 - JmsConsumer[example.zoo1]
2019-10-01 15:06:05,690 | WARN | Execution of JMS message listener failed. Caused by: [org.apache.camel.ResolveEndpointFailedException - Failed to resolve endpoint: zookeeper://localhost:2182/some/node/99 due to: No component found with scheme: zookeeper] | org.apache.camel.component.jms.EndpointMessageListener | Camel (camel) thread #1 - JmsConsumer[example.zoo1]
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: zookeeper://localhost:2182/some/node/99 due to: No component found with scheme: zookeeper
Camel Zookeeper Component
The solution works as #Bedla wrote.
Copy the Jar in the ACTIVEMQ_HOME/lib folder and it works as expceted.

In camel how to generate alert mail when active mq is down

I am using apache camel 2.x and active amq version 5.x
I have an amq where I am putting some message. Now I want to trigger an alert mail using camel when ever the amq is down .
here is my configuration details:
Code in bean
<bean id="activeMQ" class="org.apache.activemq.camel.component.ActiveMQComponent" lazy- init="true">
<property name="brokerURL" value="some url" />
Broker URL :failover:(tcp://,tcp://

Accessing OpenMQ JMS Broker from ServiceMix+Camel

I am trying to get ServiceMix+Camel talking to OpenMQ JMS Broker. I have a Camel route definition defined in Blueprint DSL which posts messages into an ActiveMQ JMS Queue. This is working fine, but I am now trying to convert this to post messages to an instance of OpenMQ running inside a Glassfish4 container.
I'm running the following configuration:
JDK 1.7.0_60
ServiceMix 5.1.1 (so Camel 2.13.2)
The documentation on this topic is somewhat minimal, but I've gathered various snippets from Google searches here and here and come up with the following (relevant parts only):
<!-- Post over JMS into Manager -->
<to uri="openmq:queue:resman"/>
<bean id="openmq" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="com.sun.messaging.ConnectionFactory">
<property name="imqAddressList" value="localhost:7676"/>
I have the following JMS related "features" enabled in Servicemix/OSGI:
[installed ] [3.2.4.RELEASE ] spring-jms
[installed ] [2.13.2 ] camel-jms
and I have the following OSGI bundles installed and active:
[ 89] [Active ] [ ] [ ] [ 50] geronimo-jms_1.1_spec (1.1.1)
[ 126] [Active ] [ ] [ ] [ 50] camel-jms (2.13.2)
The problem I have is a ClassNotFoundException at the point I deploy the Came Route Blueprint into ServiceMix. Here are the relevant snippets from the Stacktrace logged:
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to instantiate components
Caused by: java.lang.NoClassDefFoundError: javax/jms/JMSContext
Caused by: java.lang.ClassNotFoundException: javax.jms.JMSContext not found by org.apache.geronimo.specs.geronimo-jms_1.1_spec [89]
So on the assumption this is an OSGI bundling issue, I've dug down into the Camel "features" just to confirm the dependencies:
karaf#root> features:info camel-jms
Description of camel-jms 2.13.2 feature
Feature has no configuration
Feature has no configuration files
Feature depends on:
spring [3.2,4)
spring-jms [3.2,4)
camel-core 2.13.2
Feature contains followed bundles:
mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1 start-level=50
mvn:commons-pool/commons-pool/1.6 start-level=50
mvn:org.apache.geronimo.specs/geronimo-jms_1.1_spec/1.1.1 start-level=50
mvn:org.apache.camel/camel-jms/2.13.2 start-level=50
So it appears that it is the "geronimo-jms_1.1_spec" that is causing the stack trace as it can't find JMSContext. I making a big assumption that as ApacheMQ must be using the same JMS class, so it must be in the environment somewhere. Also, JMSContext seems to be a JMS 2.0 API interface, so is the issue here that the geronimo-jms_1.1_spec bundle is trying to reference a JMS2 API?
I also have the issue of getting the client JARs for OpenMQ installed into the environment. The OpenMQ client JARs shipped with Glassfish4 are plain JARs and not OSGI bundles (see, so I plan to either use the "file:wrap" feature to deploy this into ServiceMix, or otherwise unpack and re-pack into the JAR containing my Beans. I don't think this is related to this problem, but I could be wrong.
OK, managed to work this one out finally. The clue was in the reference to javax.jms.JMSContext which is new in the JMS 2.0 API. I was attempting to use the OpenMQ client libraries (imq.jar and jms.jar) taken from the Glassfish4 distribution, which is at JEE7 and hence JMS v1.1. ServiceMix 5.1.1 is still at JMS V1.1, hence the ClassNotFoundException.
When connecting to an instance of OpenMQ running under Glassfish4, you need to download and use the OpenMQ client libraries from the previous Glassfish 3.2.2 release. You can obtain this release release from the Glassfish project archives here.
Tests so far show this to be working fine, so if I find anything of relevance going forward I'll come back and update this post.

SQLException: Illegal connection port value ${env.OPENSHIFT_MYSQL_DB_PORT}

I am trying to deploy a fairly basic Spring+Hibernate web app to my newly created app. (I am new to openshift).
I have followed this example from the knowledge base.
But after deploying the application i am getting
java.sql.SQLException: Illegal connection port value '${env.OPENSHIFT_MYSQL_DB_PORT}'
I have defined the datasource in my applicationcontext.xml
This is the section in my applicationContext.xml that I define the deta shource (eli is the database name)
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
p:url="jdbc:mysql://${env.OPENSHIFT_MYSQL_DB_HOST}:${env.OPENSHIFT_MYSQL_DB_PORT}/eli" p:username="${jdbc.username}"
Any idea what I am doing wrong?
The error you're receiving seems to indicate that the property replacement strings in your Spring XML configuration aren't actually being processed by Spring. You can add a PropertyPlaceholderConfigurer to your configuration to enable processing from the system environment:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="searchSystemEnvironment" value="true" />