Archive for the ‘JMS’ Category

Flex, Java Remoting, and JMS [null message body]

07 Aug

So I was pounding out some code this afternoon, ran into a small snag and thought I’d post. Neuro-physiologists tell us that we better remember what we write down so here goes.

Similar to my post a few months ago, I made a simple omission in my coding flurry.

I was working with a backend Java class that published messages to [ActiveMQ] JMS. I wrote up a simple VO class to publish via JMS.

package com.dl.sifagents.vo;


public class ZISEventVO implements Serializable
public String eventType = "";
public String payloadPackage = "";
public String payloadElement = "";
public String xml = "";

On the Flex side, I wrote up an AS3 implementation

package com.dl.sifagents.vo
public class ZISEventVO
public var eventType:String;
public var payloadPackage:String;
public var payloadElement:String;
public var xml:String;

I published the VO to JMS…

public void publishObjectToJMS(Serializable o)
try {
ObjectMessage message = _pubSession.createObjectMessage();
_publisher.publish(message, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, 5 * 60 * 1000);
} catch (JMSException e1) {

I received the JMS message in Flex (via BlazeDS) but the message body was null. I checked and doubled checked my Java VO implementation vs AS3 VO implementation and couldn’t find any naming conflicts or errors.

Then it hit me, in my haste I’d forgotten to upload the Java VO class to BlazeDS (i.e. to the WEB-INF/classes folder)!

That’s my piece of humble pie for the week 🙂 Back to work.


Posted in BlazeDS, Java, JMS


[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