Installing BlazeDS into ColdFusion 8

I have been a huge fan of BlazeDS ever since Adobe MAX 2009 where I attended a BYOL session given by Aaron West.  However, I have never had a production use for it.  I have always been looking for a way to use it but nothing ever cam up.  Then recently we wanted to replace the alert system in our system with something more real-time.  This was a perfect opportunity to use BlazeDS.

The only issue we had was our system was still running ColdFusion 8.  BlazeDS was baked into ColdFusion 9.  ColdFusion 8 uses LCDS.  So I did some digging and found a presentation from Aaron on getting BlazeDS working inside ColdFusion 8.  What this basically does is replace LCDS with BlazeDS.  Since I was not using LCDS this would not be an issue.

So, a about a month ago I tackled getting it running on our development server.  The install was a breeze.  Aaron's video walk though was perfect and allowed me to follow right along.  After only a few minutes I was able to get it all running.  I ran into a couple configuration issues but with some assistance from Aaron those were quickly worked out.

Fast forward to now.  Using the same steps from installing BlazeDS on our dev server I went about getting it running in test.  This time I ran into a major issue that kept BlazeDS from running.  ColdFusion was throwing the following error when trying to start up after getting BlazeDS in place.

03/21 08:29:49 user MessageBrokerServlet: init
[BlazeDS]BlazeDS - Community Edition:
[BlazeDS]No login command was found for 'JRun/4.0'. Please ensure that
the login-command tag has the correct server attribute value, or use
'all' to use the login command regardless of the server.
[BlazeDS]Endpoint cf-longpolling-amf created with security: None
at URL: http://{}:{server.port}/{context.root}/flex2gateway/cfamflongpolling
[BlazeDS]Endpoint my-amf created with security: None
at URL: http://{}:{server.port}/{context.root}/messagebroker/amf
**** MessageBrokerServlet failed to initialize due to runtime
exception:   Exception: flex.messaging.MessageException: Cannot create
class of type 'coldfusion.flex.CFEventGatewayAdapter'. Type
'coldfusion.flex.CFEventGatewayAdapter' not found.
       at flex.messaging.util.ClassUtil.createClass(
       at flex.messaging.Destination.createAdapter(
       at flex.messaging.config.MessagingConfiguration.createAdapter(
       at flex.messaging.config.MessagingConfiguration.createDestination(
       at flex.messaging.config.MessagingConfiguration.createServices(
       at flex.messaging.config.MessagingConfiguration.configureBroker(
       at flex.messaging.MessageBrokerServlet.init(
       at coldfusion.flex.ColdFusionMessageBrokerServlet.init(


Basically, what this error means is that one of the jars could not be found.  Also, this error didn't prevent ColdFusion from starting.

So, after searching the interwebs I asked Aaron if he had seen this before.  After some back and forth this issue was new to Aaron as well. 

For some reason this server wanted some of the jars to be in a different place then the instructions stated.  This seemed strange since both servers were installed with the same features and both running the same OS (win2003 ent).

Here I spent a while trying to see if maybe the jars were corrupt or there were permissions issues.  None of these worked out.  What ended up working as a based on pure luck and a guess.

What was hanging it up was the placement of 2 jars and where they resided.  The instructions state to put 2 jars from the BlazeDS install here: {CF_install_dir}/wwwroot/WEB-INF/flex/jars.  The jars in question are cfgatewayadapter.jar and concurrent.jar. 

I ended up taking those 2 jars and placeing them here: {CF_install_dir}/lib . 

Once I did that ColdFusion would start without error.  Then ran some sample code I had and BlazeDS was working perfectly. 

I have not been able to determine why this server had to be configured this way.  Nor did I find any documentation supporting this change as they way it should be done.

So there you have it.  I hope that this may help someone if they run into this issue.

Till next time,


BlazeDS: Changing consumer subtopic

In BlazeDS you can use subtopics to filter messages on the server. A consumer (client) would then only receive messages based on the subtopic filter they subscribe to. This greatly reduces the load on clients and stops unwanted messages from being sent to clients.

In a recent project I needed a way for a client to change it's subtopic filter post subscribe. After some digging it was not as complicated as I thought it would be. The trick was to unsubscribe the client then have them resubscribe with the new filter.

Below is the code I am using to accomplish this. I am using the FDMS Bridge for this so, if you are using actionscript then adjust accordingly.

view plain print about
1function initPolling (sub){
2    var server = 'localhost';
3    var port = 80;
4    var cs = new ChannelSet();
6    if (sub == '' || sub == undefined){
7        sub = '0';                    
8    }
11    cs.addChannel(new AMFChannel("longpolling-amf","http://"+server+":"+port+"/flex2gateway/cfamflongpolling"));                
13    consumer = new Consumer();
14    consumer.setDestination('BasicQueue');
15    consumer.setChannelSet(cs);
16    consumer.setSubtopic("" + sub);
18    // respond to messages from blazeDS
19    consumer.addEventListener("message", messageResponseHandler);
20    consumer.subscribe();
23function messageResponseHandler(event){
24    alert(event.getMessage().getBody().MESSAGE);
27function resub(){
28    // unsubscribe and then reinit with new subtopic
29    consumer.unsubscribe();
30    initPolling(999);

Till next time..


Code from BlazeDS & ColdFusion 9 Presentation

As promised during my presentation on BlazeDS and ColdFusion 9, here is the code from the presentation. I have also included the slides so you can go through them at your leisure.

Download Code

In case you missed it. You can see the recording here. BlazeDS and ColdFusion 9...Going Above and Beyond Chat

BlazeDS & ColdFusion 9 - the onIncomingRequest mystery

In a recent blog I talked about using BlazeDS with ColdFusion 9. I explained how the gateway appeared to differ from other gateways. The gateway cfc didn't have to have an onIncomingRequest function defined. As a matter of fact the gateway didn't even need to point to a cfc at all. It could point to a blank cfm file.

After that post I talked with Aaron West about my findings in detail. Since it was his example that I used for my based he was interested in what I found. I was also contacted by Stephen Moretti as he was interested in my findings a well. The difference was that Stephen basically said what I found was not accurate. He has a BlazeDS/ColdFusion9 setup running and if he removed the onIncomingRequest his setup would fail.

Stephen and I talked a lot about his setup. We talked about the differences between what I had and what he had. What we discovered was that he was using FDMS. FDMS is the Ajax client library for BlazeDS. It allows you to use JavaScript to communicate with BlazeDS. There is still a flash component but you don't need to know flash to use it.

After knowing how Stephen was using it I went off and built another sample. After some tweaking I was able to get it up and running. I ran a few tests to verify messages were being sent then received. I then removed the onIncomingRequest function from the gateway cfc. Upon doing so I received this message:

view plain print about
1Error [Thread-16] - Error invoking CFC for gateway FlexMessagingJS: The method onIncomingMessage was not found in component /Applications/MAMP/htdocs/BlazeTesting/FDMS/gateway.cfc.

I then created a new sample to test a theory. I combined the samples I had from Aaron and Stephen to a single example. I used the code from Aaron's sample to do the send to BlazeDS. I then used Stephen's code to create the consumer. So now I have a jquery front end submitting to ColdFusion that sends the message to BlazeDS that a FDMS consumer receives.

After creating this sample I removed the onIncomingMessage from the cfc and ran some tests. This time the messages made it though without error. So, what was the major difference? Quite simple, I removed the part from the FDMS client so that it didn't register as a producer. I used jquery to send the message to ColdFusion and then have ColdFusion pass the message to BlazeDS. Thus the producer became the ColdFusion server.

In conclusion it would appear that if the message to BlazeDS is being sent by the ColdFusion server the cfc assigned to the gateway is not ran. However, if the producer is a different client then the gateway code is ran.

Till next time...


BlazeDS and ColdFusion 9 - Part 1

Lately I have been itching to build something with BlazeDS. I have seen a couple presentations on it and am very intrigued by what one could do with it. After doing some reading and a presentation on it I decided to jump in and just build something.

I grabbed the code that Aaron West created for his BlazeDS / ColdFusion 9/ Flex presentation to use as a reference. I read though his presentation docs and configured ColdFusion in just a few minutes. The rest was a snap and I had the code from his demo running in little under 30 minutes.

I then started to expand the code to do more advanced things with it. The main thing I wanted to accomplish was to send a message to a specific consumer. I found out that had to inject a custom header that the consumers could filter on. This seemed very straightforward to do. Especially since the sample code from Aaron showed how to set a header var. This simple task ended up taking me 2 days to figure out.