The amazing adventures of Doug Hughes

This entry covers some problems I ran into configuring a Flex application to work with ColdFusion Flash Remoting on Mac OS X. I am working on an Air application which will talk to ColdFusion via Flash Remoting. My components are accessible via an Apache virtual host. My virtual host answered to the domain http://photoframe, which I configured, tested and was working correctly. IE: I could put a file in the directory for that URL and pull it up via a web browser.

My next step was to create a new Flex Project in Eclipse. For the first page I provided the path to my project directory (up one level from my www directory). I indicated I’m creating an Air app. Finally, I selected ColdFusion as my server technology and that I was using ColdFusion Flash Remoting for my remote access service and clicked next to continue.

Now, honestly, I’m new to Flex. (Most of my team has been working with Flex a lot longer.) The next step in creating a Flex project has always stymied me. I never knew the correct values to to provide for this screen and, frankly, the documentation was next to useless and the default values were misleading. Tonight I realized it’s really not that complicated. In the past I thought that web root and root url fields were asking for the ColdFusion instance’s web server root. To clarify, when you install CF as either stand alone without a web server or multi-server you end up with a server you can hit via HTTP. IE: http://localhost:8500. And, if you’re running more than one instance of CF you might need a context root appended to that URL.

I figured this told Flex where to access whatever it needed to make remote calls. Turns out I was mostly incorrect. If you have ColdFusion connected to a web server (like most of the normal world) you actually simply need to create a new site, like my http://photoFrame, and provide the path to its webroot, and the URL you use to access it. So, in my case the web root was “/users/dhughes/sites/photoFrame/www” and the url was http://photoFrame. Because I’m using a web server I don’t need to provide a context root. For the ColdFusion war folder I provided the path as I expected. I simply provided “/Applications/JRun/servers/cfusion/cfusion-ear/cfusion-war”. I left the compiled location at it’s default.

Now, this is where I began to run into problems. When I clicked the button to validate the configuration I received this warning message: “Cannot access the web server. The server may not be running, or the web root folder or root URL may be invalid.” It wasn’t an error and I could click next. But, I didn’t like seeing the warning so I did a little research to see if I could figure out what’s going on.

It seems that when you click the validate button Flex Builder it writes a temporary file to disk and tries to access it via the URL you specified. I noticed in my Apache error log I was seeing messages like these:

[Sat Dec 13 18:59:19 2008] [error] [client] File does not exist: /Users/dhughes/Sites/photoFeed/www/flex_wizard_project_test_script_server_7181.htm
[Sat Dec 13 20:56:35 2008] [error] [client] File does not exist: /Users/dhughes/Sites/photoFeed/www/flex_wizard_project_test_script_server_7227.htm

I’m not sure why Flex Builder wasn’t writing those files to the correct location, but at least I know it was hitting the correct virtual host. And, though I was receiving the warning, I could click next to create the project and I did.

Now that my project was created I threw together a simple hello world CFC and some quick MXML that used to call a saHi() method on the CFC. But, when that code was run I received this error message: RPC Fault faultString=”Send failed” faultCode=”Client.Error.MessageSend” faultDetail=”Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: ‘http://hotoFrame.swf/flex2gateway/'”

Now, take a close look at that error message. Note that it’s not trying to access “http://photoFrame”, it tried to access “http://hotoFrame.swf”! I have absolutely no idea why it’s using the name of the SWF, less the first letter of it’s name, as the URL instead of http://photoFrame. Very perplexing. I spent a good long time Googling this and found absolutely nothing useful. Maybe one of my blog readers knows the answer to this.

So I went into the next best thing and asked around on #ColdFusion in IRC where Dan Wilson was luckily willing to help me. We determined that ColdFusion’s configuration was correct. (I won’t describe how it was configured because I’m still new to this. Suffice it to say it was the default.) We checked ColdFusion to confirm Flash Remoting was enabled too. Finally, Dan consulted with a friend of his who suggested we try copying five XML files from the ColdFusion WEB-INF/flex directory into our project. So, I copied these five files to a config directory I created under my project:

  • services-config.xml
  • remoting-config.xml
  • proxy-config.xml
  • messaging-config.xml
  • data-management-config.xml

Once these files were in place I edited the ColdFusion destination in the remoting-config.xml file to use a new channel, “PhotoFrame”. This could be named anything. I then edited my services-config.xml and created a new channel-definition based on the default “my-cfamf” but named “PhotoFrame”. I set the uri for this channel to be the actual, static, correct, URL for my application. IE: “http://photoframe/flex2gateway/”. Finally, I edited the compiler settings to point at the the copied services-config.xml file. Amazingly, on the next run the application loaded and was able to hit my remote CFC!

I have no idea why I had this problem, but I’m happy to have a solution.

Comments on: "Flex Builder ColdFusion Flash Remoting Problem and Resolution" (3)

  1. Thank you!


  2. WOW, amazing, this worked for me too. This has had me stumped for hours… ugh.. thanks a bunch!!! Not elegant, but it works…


  3. Took me like 2hours trying to figure this out until I read your blog and reading the apache error log.

    The validate now button when creating a flex project is meant create a test file in the “web root” dir and accesses it via “root url”.

    What it does is it creates a file in the “web root” dir
    check through the right virtual host. It checks for the first apache virtual host in httpd-vhosts.conf file. So I just moved the vhosts code block for that project to be the first in httpd-vhosts.conf.

    Well that was the problem for my config, apache2.2 with vhosts,php5, flex builder 3. So thanks for pointing me in the right direction mr blogger!


Comments are closed.

Tag Cloud

%d bloggers like this: