21 Replies Latest reply on Apr 9, 2007 3:57 PM by PaulBaylis

    Can't make Flex work with CFMX 7.0.2

    kenreiss
      I have Flex 2.0 and CFMX7.0.2 on a shared server. Following are the programs I'm trying to run when I get a "TypeError: Error #1034:
      Type Coercion failed: cannot convert Object@2f044c1 to mx.messaging.messages.ErrorMessage." error. When I click the "Button" button, it works fine with web services. When I click the "Button2" button, I get the error I mentioned. Thank you for your help!

      I really want to get Flex 2.0 running, and have spent hours trying to fix this one?! I assume others are having the same problem.

      Ken.



      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute">
      <mx:WebService id="a"
      wsdl="[MY URL HERE]/a.cfc?WSDL"
      />
      <mx:Button x="447" y="317" label="Button"
      click="a.helloWorld.send();" />
      <mx:DataGrid x="30" y="75" id="dgTopPosts" width="400"
      dataProvider="{a.helloWorld.lastResult}">
      <mx:columns>
      <mx:DataGridColumn headerText="Top Posts" dataField="f"/>
      <mx:DataGridColumn headerText="Clicks" dataField="g"
      width="75"/>
      </mx:columns>
      </mx:DataGrid>

      <mx:RemoteObject id="b"
      endpoint="[MY URL HERE]/flashservices/gateway"
      source="[MY PATH HERE]/a">
      <mx:method name="helloWorld2">

      </mx:method>
      </mx:RemoteObject>
      <mx:Button x="447" y="357" label="Button2"
      click="b.helloWorld2.send();" />
      <mx:Text x="30" y="175" htmlText="Company:
      {b.helloWorld2.lastResult.helloWorld2Result}"/>
      </mx:Application>



      a.cfc (cfmx702 server):

      <cfcomponent>
      <cffunction name="helloWorld" access="remote"
      returntype="query">
      <cfset a = QueryNew("f,g")>
      <cfset temp = QueryAddRow(a)>
      <cfset temp = QuerySetCell(a, "f", "ok", 1)>
      <cfset temp = QuerySetCell(a, "g", "then", 1)>
      <cfreturn a>
      </cffunction>

      <cffunction name="helloWorld2" access="remote"
      returntype="string">
      <cfreturn "hi">
      </cffunction>
      </cfcomponent>


        • 1. Re: Can't make Flex work with CFMX 7.0.2
          peterent Level 2
          The best way to get Flex 2 and CFMX7.0.2 to work is with RemoteObject, as you are doing. But things have changed WRT how you connect them together.

          Don't use the endpoint anymore. Instead, use destination:

          <mx:RemoteObject id="b" destination="ColdFusion" ... />

          When you compile this application, either using Flex Builder 2 or mxmlc, use the -services tag to specify the location of the services-config.xml file. When you installed CFMX7.0.2 a services-config.xml file was created in: wwwroot/WEB-INF/flex and you should put the full path for the file as the -services argument.

          You'll see in the services-config.xml file a destination id="ColdFusion" - the same name you use in the RemoteObject.

          You can read more about this in the documentation that comes with CFMX7.0.2
          • 2. Re: Can't make Flex work with CFMX 7.0.2
            I'mAndy
            I have no problems getting remoteobject to work on a local machine using the following code

            <mx:RemoteObject
            id="svc" destination="ColdFusion" source="components.mlbSeqs"....
            </mx:RemoteObject>

            However when I upload the relevant swf/html files to my host server I get the error

            [RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed"]
            at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::faultHandler()
            at mx.rpc::Responder/fault()
            at mx.rpc::AsyncRequest/fault()
            at mx.messaging::ChannelSet/::faultPendingSends()
            at mx.messaging::ChannelSet/channelFaultHandler()
            at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
            at flash.events::EventDispatcher/dispatchEvent()
            at mx.messaging::Channel/mx.messaging:Channel::connectFailed()
            at mx.messaging.channels::PollingChannel/mx.messaging.channels:PollingChannel::connectFailed ()
            at mx.messaging.channels::AMFChannel/mx.messaging.channels:AMFChannel::statusHandler()

            Should I be compiling it differently for a remote server ref the services-config.xml or putting a crossdomain.xml file somewhere?

            cheers
            • 3. Re: Can't make Flex work with CFMX 7.0.2
              peterent Level 2
              The solution lies in your services-config.xml file. If you open that up you'll see something like this:

              <channels>
              <channel-definition id="my-cfamf" class="mx.messaging.channels.AMFChannel">
              <endpoint uri=" http://{server.name}:{server.port}{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
              <properties>
              <polling-enabled>false</polling-enabled>
              <serialization>
              <instantiate-types>false</instantiate-types>
              </serialization>
              </properties>
              </channel-definition>
              </channels>

              which is the definition for your local CF gateway. All you need to do is change the <endpoint> to your remote server which also has the 7.0.2 update installed.

              If you do this often, I'd make a copy of the services-config.xml file and use that when you build for a different CF server.
              • 4. Re: Can't make Flex work with CFMX 7.0.2
                I'mAndy Level 1
                Thanks Peter but not sure I have quite got this yet

                I have created a new services-config.xml in in: wwwroot/WEB-INF/flex/remote
                with a nonsense endpoint
                <endpoint uri=" http://www.zzzzzzzzzzzzoootr.com:80/flex2gateway/"

                I then create a new cf remoting Flex project with the wizard and change the additional compiler arguments to
                -services "C:\CFusionMX7\wwwroot\WEB-INF\flex\remote\services-config.xml" -locale en_US

                However, the project still works locally returning data. How come?

                Also, I'm not sure what I should be putting in each of variables
                {server.name}:{server.port}{context.root}/flex2gateway/"

                presumably server.name is mysite.com
                Is there a default server.port? and what does context.root mean. do i need to ask the host

                • 5. Re: Can't make Flex work with CFMX 7.0.2
                  kenreiss Level 1
                  Peter: Thank you for your reply.

                  1. I tried what you said, and my Flex Builder now keeps showing an error that it is unable to open 'c:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml' -- Aparently, it's looking for it on my local machine, not on my seb server.

                  2. Where do I find the documentation that came with CMFX7.0.2? I looked all over and can't find it.

                  3. If I do have to modify the services-config.xml file, I can do that on my devel server. However, on my shared production servers, I can't - how can I still use AMF/FlashRemoting?

                  4. Does this have anythign to do with the new "Server Identity" field in the Flex Integration menu of CFAdministrator?

                  Thank you for your help. Perhaps someone at Adobe can make a simple tutorial of how to run through this process. It seems to me that this would be one of the most common processes and I can't find anything documenting it.

                  Ken.
                  • 6. Re: Can't make Flex work with CFMX 7.0.2
                    I'mAndy Level 1
                    Sorry, I thought I had recompiled with the odd entry in services-config file but clearly had not when I amended mxml further
                    However, would still appreciate help with last point
                    cheers
                    • 7. Re: Can't make Flex work with CFMX 7.0.2
                      biedy
                      I just tried an example from adobe site which using the coldfusion 7.0.2 and flex 2.0 beta 3. In the first place, i got few errors coming out from my screen, i thought it got something to do with the coldfusion administration setting but then it got nothing to do at all with the configuration. The configuration by default is fine. I just find out it got some thing to do with the addtional compiler arguments which the file i download from Ben Forta Blog. The filename is flex-enterprise-services.xml. After that you have to make sure that your cfc located on the correct directory which refer back to your flex-enterprise-service.xml configuration. Walla!!! Finally, last night it just worked fine for me. I hope this work on your side. Good Luck.
                      • 8. Re: Can't make Flex work with CFMX 7.0.2
                        Friedmarc
                        Ken I feel your pain!

                        I too am having trouble connecting via remote object as well as web service.
                        I am running CFMX 7.0.2 locally as a test server.
                        Before I got started I ran a test to make sure that DAO.cfc was working and all tested just fine.

                        When I try to connect with remote object I get this error:
                        ==========================================
                        [RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error
                        NetConnection.Call.Failed: HTTP: Status 500"]
                        at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::faultHandler()
                        at mx.rpc::Responder/fault()
                        at mx.rpc::AsyncRequest/fault()
                        at mx.messaging::ChannelSet/::faultPendingSends()
                        at mx.messaging::ChannelSet/channelFaultHandler()
                        at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                        at flash.events::EventDispatcher/dispatchEvent()
                        at mx.messaging::Channel/mx.messaging:Channel::connectFailed()
                        at mx.messaging.channels::PollingChannel/mx.messaging.channels:PollingChannel::connectFailed ()
                        at mx.messaging.channels::AMFChannel/mx.messaging.channels:AMFChannel::statusHandler()


                        When I try to change and acces the DAO as a web service I get this result:
                        =========================================================================
                        result = [object Object],[object Object],[object Object],[object Object]........


                        The CODE:

                        C:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml
                        ======================================================
                        <destination id="someSVC">
                        <channels>
                        <channel ref="my-cfamf"/>
                        </channels>
                        <properties>
                        <source>myapp.DAO</source>
                        <lowercase-keys>true</lowercase-keys>
                        </properties>
                        </destination>


                        <channels>
                        <channel-definition id="my-cfamf" class="mx.messaging.channels.AMFChannel">
                        <!--<endpoint uri=" http://{server.name}:{server.port}{context.root}/flex2gateway/"

                        class="flex.messaging.endpoints.AMFEndpoint"/>-->
                        <endpoint uri=" http://localhost:8500/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
                        <properties>
                        <polling-enabled>false</polling-enabled>
                        <serialization>
                        <instantiate-types>false</instantiate-types>
                        </serialization>
                        </properties>
                        </channel-definition>
                        </channels>


                        Compler argument for project:
                        ============================
                        -services "C:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml" -locale en_US


                        Remote Object Call in MXML App.
                        ==========================
                        <mx:RemoteObject
                        id="foo"
                        destination="someSVC"
                        result="Alert.show('result = ' + event.result, 'Result')"
                        fault="Alert.show('error = ' + event.fault, 'Error')"
                        showBusyCursor="true"/>

                        Web Service Call in MXML App.
                        ========================
                        <!--<mx:WebService id="foo"
                        wsdl=" http://localhost:8500/myapp/DAO.cfc?wsdl"
                        result="Alert.show('result = ' + event.result, 'Result')"
                        fault="Alert.show('error = ' + event.fault, 'Error')"
                        showBusyCursor="true" />

                        DataGrid:
                        =========

                        <mx:DataGrid width="664" height="99" editable="false"
                        showHeaders="true" id="test" dataProvider="{foo.method.Result}" left="43" top="92">

                        <mx:columns>................


                        Hope someone can help, would love to get up and running at this point.
                        Thanks!
                        • 9. Re: Can't make Flex work with CFMX 7.0.2
                          I'mAndy Level 1
                          Agreed a tutorial would be MUCH appreciated
                          I have attempted to follow Peter Ent's advice for my problem but am little nearer a solution
                          I now get a sandbox violation
                          "Security sandbox violation: http://mysite.com/mlb/rem3.swf cannot load data from http://www.mysite.com/flex2gateway/"
                          but am unclear whether this is due to me misconfiguring the services-config.xml file, the need for a crossdomain file (I have one on the remote site - but it may be invalid) or something else
                          I am also unclear whether, specifying the server root in the wizard as the local cold fusion server has any implications for projects that are being uploaded to a remote
                          • 10. Re: Can't make Flex work with CFMX 7.0.2
                            phillips1021
                            I've got the same problem as Andy. My Flex app works fine on my development box. But when I upload everything to my server, I get the same error as Andy.

                            On my development box I've specified this in the Flex Compiler as an additional argument

                            -services "C:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml" -locale en_US

                            Do I need to specify the location of the services-config.xml file that is on my server?

                            Bruce
                            • 11. Re: Can't make Flex work with CFMX 7.0.2
                              kenreiss Level 1
                              Peter Ent:

                              We still can't make this work. Can you please help? Perhaps a tutorial on how to get started using Flex 2.0 and ColdFusion 7.0.2 together when CF is on a remote server would be helpful.

                              I found this acticle to be helpfuly for running CFMS7.0.2 locally, but for a production product, I can't run it locally: http://www.adobe.com/devnet/flex/articles/helloworld.html

                              HELP!!

                              Ken.
                              • 12. Re: Can't make Flex work with CFMX 7.0.2
                                ANSCORP Level 1
                                A couple of things you might want to check: first, the CF 7.02 Update Documentation pertaining specifically to the Flash Remoting update can be found here: http://download.macromedia.com/pub/documentation/en/flex/2/using_cf_with_flex2.pdf (pages 5 through 11)
                                Second, if you haven't already done so, any CFCs being invoked within your RemoteObject tags must be duplicated on the server on which you're deploying your Flex application in the same path referenced when you compiled the app. This is kind of a no-brainer, but it's still something to check.
                                Third, if I'm reading the documentation correctly, you only have to create a destination in the services-config.xml file if you choose to do so. Otherwise, just use "destination=ColdFusion" when creating your RemoteObject in mxml and specify the path (from your web root) to the CFC in dot notation in the "source" attribute of the RemoteObject tag (eg. destination="myappfolder.componentsfolder.cfcname").
                                Fourth, if your cfc is returning a query result to Flex, it's best to have an actionscript class file to translate the data to a usable object. Otherwise, you end up with an untyped object which can be hard to work with (at least for me). If you use the ColdFusion extensions for Flex Builder to build a simple application, it writes all the actionscript class files for you, which is a good starting point to figure out what's going on. It's all in the docs.....
                                There is a wealth of documentation on this stuff if you just dig around a bit, although some of it is harder to find than it should be. Also, I've noticed that there are not too many application and code examples that use Flash Remoting.
                                Perhaps my biggest gripe about Flex thus far is that 3rd-party books covering Flex 2 development won't hit the stores until the September, October, November time frame. This speaks more to my own need for "hand-holding" than it does for the product, though.

                                Good Luck,
                                M. McConnell
                                • 13. Re: Can't make Flex work with CFMX 7.0.2
                                  charlie@carehart.org Adobe Community Professional & MVP
                                  As for awaiting 3rd party books, I'll just throw out that (as is so often the case) we don't want to forget the product documentation itself. In the case of Flex 2, there are several books, some hundreds and some of thousands of pages long. Lots of goodness to get one way down the road, without waiting for third parties. :-)

                                  I realize that you probably mean you want something in hard-copy, but note that the docs are indeed sold. I would also think you can legally print the PDFs yourself for your own personal use, and especially if (as opposed to the doc sets) you only want some one book. I'd certainly appreciate anyone from Adobe clarifying if we can legally print hardcopy of the PDFs for personal use.

                                  That said, as for getting the docs in hard-cover, there are a couple problems that an Adobe rep may also want to look into. first, the docs page ( http://www.adobe.com/support/documentation/en/flex/) offers a link ( http://www.adobe.com/go/buy_books) to get the books but sadly it doesn't offer a Flex set.

                                  And if one does go find the store page for the flex docs (https://store1.adobe.com/cfusion/store/index.cfm?store=OLS-US&view=ols_cat&catType=BOOKS &NR=0#loc=en_us&view=ols_prod&store=OLS-US&categoryOID=1140257&catType=BOOKS&NR=0) it sure seems that those are Flex 1.5 books and titles. They don't say Flex 2, as the docs on the doc page do, nor are the Developer's Guide or Flex Builder manuals listed.

                                  Until we can buy them printed, does anyone know if we can legally make hard-copy printouts of Adobe docs, for personal use (and not for resale)? My read of the license page on the inside front cover of the Flex 2 Developer's Guide doesn't speak to this specifically, saying instead that it's copyright material. I've done a bit of googling to find if there is some clearly generic guidance but have found none.
                                  • 14. Re: Can't make Flex work with CFMX 7.0.2
                                    kenreiss Level 1
                                    Thank you for your help, guys. I have read the Flex 2 with CFMX7.0.2 docs you sent and they were somewhat helpful. I tried all sorts of things and still continue to get the following error message:

                                    [RPC Fault faultString="[MessagingError message='Unknown destination 'ColdFusion'.']" faultCode="InvokeFailed" faultDetail="Couldn't establish a connection to 'ColdFusion'"]
                                    at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::invoke()
                                    at mx.rpc.remoting.mxml::Operation/ http://www.adobe.com/2006/flex/mx/internal::invoke()
                                    at mx.rpc.remoting::Operation/send()
                                    at Function/ http://adobe.com/AS3/2006/builtin::apply()
                                    at mx.rpc.remoting.mxml::Operation/send()
                                    at testwebservices/___Button2_click()

                                    I am running IIS5.0 with multiple virtual hosts. This is one of the virtual hosts.

                                    I have the following line in my Flex Builder 2:

                                    --services=c:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml

                                    and always get a "unable to open 'c:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml'" error becaue of course I don't have this file on my development machine - its on my remote server and my local machine can't see it's C:\ drive.

                                    I searched my server's entire C drive and don't see the flex2gateway folder anywhere.

                                    Perhaps it's my source attribute? The docs say "The source attribute specifies the dot notation to the CFC from the web root(the classpath to the CFC)." But what is my webroot on a shared server? There is no dot notation to point to it from either my c:\inetpub\wwwroot or c:\cfusionmx7\wwwroot because my CFC is in my e:\ drive in a virtual host folder.

                                    Has ANYONE successfully gotten Flex 2 to work with CFMX7.0.2 on IIS5.0 with multiple domains? If so HOW? I beleive Flex 2 is great, but it won't be any good to me if I can't get it to run on a live production server. I was one of the first ones to buy it back at the end of June, and it's been nearly a month and I still can't make it work.

                                    VERY FRUSTRATED,
                                    Ken.
                                    • 15. Re: Can't make Flex work with CFMX 7.0.2
                                      ANSCORP Level 1
                                      Kenreiss,

                                      If you don't have a local installation of ColdFusion running, you're going to need to point the compiler argument to an administrative share or something where CF 7.02 has been installed. For example, on your local development machine, you'd have to map a drive letter (let's use "T") to the drive on your remote server (assuming you have such access) where ColdFusion is installed. If you do this from a command prompt, it would look something like: netuse t: \\webservername\c$
                                      This assumes that the ColdFusion directory is located on the "C" volume of the remote server and that you have access to map an administrative share. Once you have the drive mapped (it will appear as the "T" drive on your local development system), you would alter the compiler argument as follows:

                                      --services=T:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml

                                      Basically, you're just replacing the "C" drive reference with the "T" drive reference, which is the admin share you created to your remote CF server.

                                      You will not find a "Flex2gateway" folder anywhere because it doesn't exist. If I remember correctly from working with Flash remoting, this is simply a reference to a virtual gateway and there is no physical path associated with it.

                                      Good Luck,
                                      M. McConnell
                                      • 16. Re: Can't make Flex work with CFMX 7.0.2
                                        kenreiss Level 1
                                        Thank you, ANSCORP. I just tried what you suggested and it took me one step further. The error now has changed because it can't find my CFC inside the webroot, because it's on another drive (E:).

                                        1. How do I talk to it there?

                                        2. What happend when I deploy this on a live, shared box, when I can't point to its mapped drive? It seems to me I should be able to point right to the domain name, rather than having to create a mapped drive?

                                        3. I noticed that it asked for my windows authentication when I clicked on my button in my flex 2 compiled swf. That indicates that the flash player is actually talking to my mapped windows drive at that time. How would this work when its deployed for real and the client's machine can't see my mapped drive over the Internet?

                                        THANK YOU!
                                        Ken.

                                        PS - Further discussion re: this topic is also at http://www.forta.com/blog/index.cfm/2006/2/1/ColdFusion-Flex-2-Sample-Application#cA187C65 7-3048-80A9-EF180EF1B77134B8
                                        • 17. Re: Can't make Flex work with CFMX 7.0.2
                                          ANSCORP Level 1
                                          Ken,

                                          That's generally the way these types of problems are solved.....one error message at a time.

                                          #1 - Your web server should define the resources to which it has access relative to it's root. Not being terribly familiar with the way you're set up, I don't want to guess and send you on a wild goose chase so I'll answer your question in general terms. If the file system on your web server is set up as follows: C:\Inetpub\WWWRoot\MyProjectFolder\Components\myCFC.cfc, then the "dot notation" to your CFC will be "MyProjectFolder.Components.myCFC". This is the path you'll place in your RemoteObject tag in the "source=" attribute. If the project folder and CFC reside on a different disk volume than the default web root, then your IIS administrator has undoubtedly created a virtual directory for that location. In other words, if the physical path to your CFC on the web server looked something like "E:\WebFolder\MyProjectFolder\Components\myCFC.cfc" and your IIS administrator set the virtual directory to "E:\WebFolder", then the path in your "source=" attribute would be "WebFolder.MyProjectFolder.Components.myCFC". You needn't be concerned with the drive letter because the path is defined relative to the Web Root.

                                          #2 If you are unable to map an administrative share or a shared folder on the server to which you will eventually deploy your files, perhaps the web server administrator can give you a copy of the services-config.xml file and you can compile against it on your local machine. I've never tried this so I don't know if it would work. You'd have to specify the correct path to the xml file in the compiler directive (eg. "C:\SomeFolder\services-config.xml") to get it to work. To be honest, I've never had to do this and I don't even know if it would work correctly. I've also never tried to compile an app using UNC so, again, I don't know if that would work, either (I tend to think not).

                                          3# It sounds to me like there may be a problem with the way the web directory is shared, or not shared as the case may be. You shouldn't be prompted for a login ID unless your web Administrator has set up something other than the default anonymous access to a virtual directory. You might want to consult with the site administrator to see what's up.

                                          Sounds like you're close to making your data connection. I hope this helps.

                                          Thank You,
                                          M. McConnell
                                          • 18. Re: Can't make Flex work with CFMX 7.0.2
                                            kenreiss Level 1
                                            I finally got the remote, shared server with CFMX 7.0.2 working with a Flex 2.0 app via AMF!

                                            Here's how I did it:

                                            http://www.kenreiss.com/blog/index.cfm/2006/8/10/F...

                                            Thank you all for your help!
                                            Ken.
                                            • 19. Re: Can't make Flex work with CFMX 7.0.2
                                              kenreiss Level 1
                                              I finally got the remote, shared server with CFMX 7.0.2 working with a Flex 2.0 app via AMF!

                                              Here's how I did it:

                                              http://www.kenreiss.com/blog/index.cfm/2006/8/10/Flex-20-with-CFMX-702--SUCCESS

                                              Thank you all for your help!
                                              Ken.
                                              • 20. Re: Can't make Flex work with CFMX 7.0.2
                                                peterent Level 2
                                                Thanks, Ken.

                                                I'm going to take your blog entry, verify it, then see if we can't use it to make our documentation clearer.

                                                Much appreciated.
                                                • 21. Re: Can't make Flex work with CFMX 7.0.2
                                                  PaulBaylis
                                                  It would be awesome if some kind soul would create a comprehensive set of steps from start to finish, beginning with creating the project in FB2. I would pay for such an instructional document. I'm completely lost at the moment. I've checked Ken Reiss' blog but don't get the same success he had. There are bits missing and things not clear enough for absolute newbies like me.