Railo, BlazeDS and CFC instances

There is a lot of buzz recently around Railo since version 3.1 finally went open source and many well known CF developers joined the project. This gave me the motivation to finally see how Railo really works. I decided to give it a shot on one of already running applications. The choice was made, I selected a Flex application powered by ColdFusion 8.1 utilizing Adobe ColdFusion classes, providing 20 different gateways, using ODBC data sources and operated with very rich and sophisticated Flex UI exchanging data using typed VOs.

First experience was great. No issues at all, application started very quickly, what takes about 20 seconds on ColdFusion is almost immediate on Railo. All CFCs worked fine, even those using internal ColdFusion classes. Overall performance was fantastic, all JDBC ODBC connections running smoothly. I have to admit that Railo guys have done really great job.

It was time to test Flex UI, a major issue popped out straight away. Railo provides integration with Adobe’s open source Blaze Data Services. It appears to work perfectly fine with all standard CFML types, strings, structures, arrays, etc., however not with CFCs. At the current state Railo is not able to serialize and deserialize them. Below is the sample test case.

Service.cfc that Flex talks to:

[source lang='cf']


  
  
    
    
  

  
  
   
   
   
   
  


[/source]

And here is the source of com.gruchalski.railo.test.TestCFC:

[source lang='cf']

  
  
  
  

[/source]

To access the service I am using following Flex application:

[source lang='as3']



  
    

  

  
  


[/source]

with this com.gruchalski.railo.test.TestCFC VO:

[source lang='as3']
package com.gruchalski.railo.test {

  [RemoteClass(alias="com.gruchalski.railo.test.TestCFC")]
  public class TestCFC {
    public var property1:String = "";
    public var property2:Number = 0;
  }
}
[/source]

When loading a CFC instance following issue is reported:

faultCode:Server.Processing faultString:’An error occurred while serializing server response(s).’ faultDetail:’null’

In case of sending a VO:

faultCode:Server.Processing faultString:’flex.messaging.MessageException: railo.runtime.exp.UDFCasterException : invalid call of the function getCfc, first Argument (INST) is of invalid type, can’t cast Object type [Struct] to a value of type [com.gruchalski.railo.test.TestCFC]‘ faultDetail:’null’

First one is obvious, BlazeDS does not know how to serialize CFC provided by Railo. Second issue is probably caused by the fact that Railo does not treat magic structures as CFCs. What I call a magic structure looks like this:

[source lang='cf']

  struct = structNew();
  struct.property1 = "Some property";
  struct.property2 = 20;
  struct.__type__ = "com.gruchalski.railo.test.TestCFC";

[/source]

When structure like that comes from the outside world or is being sent to outside world (for example BlazeDS iteraction or SOAP request) Adobe ColdFusion treats it as a CFC instance.

Despite the issue I think Railo is a very good choice in its current state. For most small applications current BlazeDS integration level is enough, new applications can easily use what is there right now. And I am sure that Railo team is working hard to enable full support.

It is good however to know the limitations before making the switch to Railo, specially when so many people consider to do so.

One Response to “Railo, BlazeDS and CFC instances”

  1. Shimju David Says:

    Hello Radek,

    Can you try this again with Railo 3.1, I think this issue is resolved now.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>