activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From petera <>
Subject Re: activeMQ embedded broker in separate war
Date Tue, 17 Oct 2006 11:17:23 GMT

I am having the same problem using the embedded broker in Tomcat 5.5 in two
separate web apps.

I have the activemq.xml (SEE BELOW) called in my first web app as follows in
the context.xml :

        description="JMS Connection Factory"

Yet when I try to connect in the second web app using: 

        description="JMS Connection Factory"

I get the following error message: 
Could not connect to broker URL: tcp://localhost:61616. Reason: Connection refused

What I doing wrong ??

TIA Peter


  <!-- Allows us to use system properties as variables in this configuration
file -->
  <broker useJmx="true" xmlns="">
      <journaledJDBC journalLogFiles="5" dataDirectory="../activemq-data"
       <transportConnector name="default" uri="tcp://localhost:61616"
       <transportConnector name="stomp"   uri="stomp://localhost:61613"/>
      <!-- by default just auto discover the other brokers -->
      <networkConnector name="default" uri="multicast://default"/>
      <networkConnector name="host1 and host2"
uri="static://(tcp://host1:61616,tcp://host2:61616)" failover="true"/>
  <!--  This xbean configuration file supports all the standard spring xml
configuration options -->
  <!-- Postgres DataSource Sample Setup -->
  <bean id="postgres-ds" class="org.postgresql.ds.PGPoolingDataSource">
    <property name="serverName" value="localhost"/>
    <property name="databaseName" value="efed-messaging"/>
    <property name="portNumber" value="0"/>
    <property name="user" value="activemq"/>
    <property name="password" value="activemq"/>
    <property name="dataSourceName" value="postgres"/>
    <property name="initialConnections" value="1"/>
    <property name="maxConnections" value="10"/>


James.Strachan wrote:
> On 8/2/06, Hyatt <> wrote:
>> I am an ActiveMQ newbie.  I am having some of the same issues expressed
>> in
>> this thread.  I'd like to use embedded broker(s); but, I want to separate
>> the management web-app (console example) from the end-user web-app (chat
>> example).
>> + Config and run the ActiveMQ web-console example: Okay, Done, works
>> great
>> + Config and run the ActiveMQ chat example: Okay, Done, works great
>> + Run the web-console AND the chat example, as two separate web-apps:
>> Crash,
>> Burn, Smoke, Fire (I can reproduce and send errors if needed, but the
>> errors
>> are more inline with other email threads about Journal file already
>> in-use
>> and cannot create broker because broker is already running....I read
>> those
>> threads, and decided that the solutions provided here are closer to what
>> I
>> think I need).
> So WARs are their own separate class loaders. So running an embedded
> broker in each war will cause problems as you are really running 2
> brokers.
> So either...
> (i) put the ActiveMQ classes in your system classpath so there is only
> 1 broker shared in each WAR's class loader
> (ii) remove the embedded broker from one of the wars and connect to
> the embedded broker via tcp
> We could also change the web console so that it doesn't use an
> embedded broker but so that it connects to the other broker via JMX.
>> Let's start with the chat example, and start with James Strachan's
>> comment:
>> > The VM transport only works when the JMS client and broker are in the
>> > same classloader. If you are using 2 separate WARs then the VM
>> > transport cannot be used - so you'll have to use TCP to connect to the
>> > same broker
>> Excellent, I've read that embedded brokers can be created with EITHER:
>> vm://localhost OR tcp://localhost:port.  CORRECT?
>> I changed the web.xml file.  I changed what worked (vm://localhost) to (I
>> tried all of these):
>> tcp://localhost FAILED
>> tcp://localhost:61616 FAILED
>> tcp://localhost:8084 (the port used by NetBean's Bundled Tomcat server at
>> runtime) FAILED
>> If I can get the chat example to work with an embedded broker using
>> tcp://
>> rather than vm://, then I should be able to use the rest of the
>> information
>> in this thread to access the embedded broker from two web-apps.
>> Am I doing enough by changing the web.xml, or do I need to change the
>> broker
>> connections in the Java code?  What am I doing wrong?
>> Using Linux, Tomcat, ActiveMQ 4.0.1, Java 1.5
>> Thanks for your help.
> So configure an embedded broker in one of the WARs with a speciifc TCP
> port (e.g. using the default activemq.xml that comes with the web
> console) - then connect to it with tcp://localhost:61616
> -- 
> James
> -------

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message