[Tunkey] BlazeDS JMS ActiveMQ

01 Aug

I spent some time this week with BlazeDS and JMS. I wanted to integrate a Flex RIA with some [existing] backend Java classes. One goal was to interface the two in a loosely coupled fashion, enter Java Message Service (JMS).

The RIA uses a mx:producer to publish messages to a JMS topic which the backend Java class is listening in on [consuming] elsewhere in the enterprise. I used an ‘external install’ of ActiveMQ.

I downloaded the turnkey BlazeDS server to get things rolling.

I came across a few great posts in looking into this…

Michael Martin’s Simplified BlazeDS and JMS

Christophe Coenraets
Flex and JMS: Portfolio Viewer (LCDS jRun)
30 Minutes Flex Test-Drive for Java Developers (FDS)

To be helpful, I’ve included some error messages and their causes:

Flex Runtime Error:
There was an unhandled failure on the server. MessageClient has been invalidated.
Cause: ActiveMQ not running.

Flex Runtime Error:
Type ‘com.dl.samples.PersonVO’ not found.
Cannot create class of type ‘com.dl.samples.PersonVO’.
Cause: Java classes not on server.

Java Runtime Error
javax.naming.NameNotFoundException: messageTopic
at org.apache.activemq.jndi.ReadOnlyContext.lookup(
at javax.naming.InitialContext.lookup(Unknown Source)
at Chat.(
at Chat.main(
Cause: not present for java class

Java Runtime [BlazeDS] Error
[BlazeDS] JMS consumer for JMS destination ‘[destinationName]‘ is being removed from the JMS adapter due to the following error: Name jms is not bound in this Context
[BlazeDS] JMS consumer for JMS destination ‘[destinationName]‘ is stopping.
[BlazeDS] The corresponding MessageClient for JMS consumer for JMS destination ‘[destinationName]‘ is being invalidated

Cause: context.xml Resource names do not match messaging-config.xml connection-factory / destination-jndi-name tags. (i.e. the ‘org.apache.activemq.ActiveMQConnectionFactory’ resource name in context.xml should match the connection-factory value in messaging-config and the ‘org.apache.activemq.command.ActiveMQTopic’ resource name in context.xml should match the destination-jndi-name value in messaging-config).

Adding the logging pattern ‘Service.Message.JMS’ to your services-config.xml can be very helpful in debugging BlazeDS JMS problems.

Here are the config files


<?xml version="1.0" encoding="UTF-8"?>
<service-include file-path="messaging-config.xml" />
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://localhost:8400/BlazeTest/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
<target class="flex.messaging.log.ConsoleTarget" level="Debug">
<prefix>[BlazeDS] </prefix>


<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service" class="">
<adapter-definition id="actionscript" class="" default="true" />
<adapter-definition id="jms" class=""/>
<channel ref="my-amf"/>
<destination id="simpleJMS">
<channel ref="my-amf"/>
<adapter ref="jms"/>


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "">
<description>BlazeDS Application</description>
<!-- Http Flex Session attribute and binding listener support -->
<!-- MessageBroker Servlet -->


<?xml version="1.0" encoding="UTF-8"?>
<Context path="/BlazeTest">
<Resource name="TopicConnectionFactory"
description="JMS Connection Factory"
<Resource name="messageTopic"
description="a simple topic"

Using the above messaging-config’s destination the message will come across as an ObjectMessage in Java :)


Posted in BlazeDS, JMS


Leave a Reply


To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

  1. Keith

    February 19, 2009 at 3:08 pm

    Since there seems to be a bud in tomcat 6.0.18 where the context.xml isn’t being copied to conf/engine/host/appname.xml, is there a way to incorporate the context.xml into the apps web.xml. ANother interesting thing is if you add the context.xml file and place it in the webapps META-INF dir, tomcat wont process it if the apps warfile in there. If you remove the war it will pick it up and the app works. Your thoughts, Thanks Keith

  2. MrKoin

    February 10, 2010 at 4:36 pm

    Hi Joshua,

    I’ve taken Christophe Coenraets blazeDS integration example (last one : RC1V2) and I had to face a really ugly problem:
    I opened two browser to see synchronisation mechanism using JMS and it worked ; but when I want to open the site from another computer than the one which host the site (the localhost) then the synchronisation mechanism is not working (data are accessible, site is enabled but data refresh does not work and no error in logs or client browser).
    Perhaps this is due to my bad knowledge concerning tomcat configuration… but I’m still stuck.
    Could you please tell me if there’s a solution to fix this or any help on configuration ?

    Thx ;)