This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Skip to end of metadata
Go to start of metadata

Configuration issues for Tomcat 7 and later

Tomcat needs to be configured to ignore Jetty SCI annotations so that the Jetty WebSocket ServerContainerInitializer class is not inadvertently picked up by Tomcat. For more information on this problem see AMQ-6154 and and consult the Tomcat documentation for the version you are using to properly exclude the Jetty jar files from being scanned by Tomcat.

Pre-integrated Tomcat with ActiveMQ

Apache TomEE is a distribution of Tomcat with fully integrated ActiveMQ. All integration steps detailed here have already been done. The stack supports injection of Topic, Queue and ConnectionFactory references as well as transactional sending and delivery.

Something like the following works out of the box with no configuration:

import javax.annotation.Resource;
import javax.servlet.http.HttpServlet;
import javax.jms.Topic;
import javax.jms.Queue;
import javax.jms.ConnectionFactory;

public class MyServet extends HttpServlet {

    @Resource(name = "foo")
    private Topic fooTopic;

    @Resource(name = "bar")
    private Queue barQueue;

    private ConnectionFactory connectionFactory;

Manually integrating Tomcat and ActiveMQ

Note, manually integrating ActiveMQ with Tomcat does allow for Topic, Queue, and ConnectionFactory injection but does not support transactional sending and delivery.

You should go to Tomcat documentation and read JNDI Resources HOW-TO, especially part: Configure Tomcat's Resource Factory.

ActiveMQ has ready JNDI resource factory for all its administered objects: ConnectionFactory and destinations.

You must provide it as a parameter factory for your resources:

<Context ...>
  <Resource name="jms/ConnectionFactory" auth="Container"
  <ResourceParams name="jms/ConnectionFactory">


If you are using Tomcat 5.5 or later then try this instead...

  <Resource name="jms/ConnectionFactory" auth="Container" type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory" brokerURL="vm://localhost" brokerName="LocalActiveMQBroker"/>


Also, don't forget to put ActiveMQ and dependent jars to tomcat shared lib directory.

Creating destinations in Tomcat 5.5 or later

This is completely untested but should work (smile)

  <Resource name="jms/someTopic" auth="Container" type="org.apache.activemq.command.ActiveMQTopic" description="my Topic"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="FOO.BAR"/>

  <Resource name="jms/aQueue" auth="Container" type="org.apache.activemq.command.ActiveMQQueue" description="my Queue"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="FOO.BAR"/>

JMX Tip when working with Tomcat

If you want to use JMX with Tomcat and then connect via JConsole to view the JMX MBeans of the server then set the following

  • No labels


  1. Unknown User (

    In Tomcat 5.5 configuration provided with conf/context.xml should be like this:

      <Resource name="jms/ConnectionFactory" auth="Container" type="org.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory"
    	factory="org.activemq.jndi.JNDIReferenceFactory" brokerURL="vm://localhost" brokerName="LocalActiveMQBroker" useEmbeddedBroker="true"/>
  2. reference to classes are not updated. Just append the apache package name :

    • org.activemq.jndi.JNDIReferenceFactory to org.apache.activemq.jndi.JNDIReferenceFactory
    • org.activemq.ActiveMQConnectionFactory to org.apache.activemq.ActiveMQConnectionFactory