15 Replies Latest reply on Apr 24, 2008 8:54 AM by spacehog

    RemoteObject Error

    spacehog Level 1
      I am banging my head on the wall. All I am trying to do is make a simple connection from a CFC to a basic flex app (I just want to see it done.) Every route I try ends up in failure. So I am begging for some help.

      I have CF 7.0.2 installed locally on my laptop. I am using port 8501 because 8500 is being used by CF8.
      CF7 is installed at c:\CFusionMX7
      The Flex project is at: C:\CFusionMX7\wwwroot\flexclasses\testCFC and the cfc (testVar.cfc) is in a subfolder called cfc.

      My CFC is basic it is just returning a string.

      The Flex project is calling the CFC and all I want to do is display the string in a text field on a panel. Here is the code:

      testVar.cfc
      <cfcomponent >
      <cffunction name="getVar" access="public" returntype="string">
      <cfset testVar = "Just Testing">
      <cfreturn testVar>
      </cffunction>
      </cfcomponent>

      My crossdomain.xml is located in my C:\CFusionMX7\wwwroot path and looks like this:
      <?xml version="1.0" encoding="iso-8859-1" ?>
      <cross-domain-policy>
      <allow-access-from domain="*"/>
      </cross-domain-policy>


      My Flex file
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      creationComplete="RO.getVar()"
      layout="absolute">
      <mx:RemoteObject
      id="RO"
      destination="ColdFusion"
      source="cfc.testVar">
      <mx:method name="getVar"/>
      </mx:RemoteObject>
      <mx:Canvas width="80%" height="80%" backgroundColor="blue" backgroundAlpha="0.17" cornerRadius="0">
      <mx:Panel width="217" height="205" x="106.5" y="156">
      <mx:Text text="{RO.getVar.lastResult}"/>
      </mx:Panel>
      </mx:Canvas>
      </mx:Application>

      When I run the app this is the error I get:

      [RPC Fault faultString="[MessagingError message='Unknown destination 'ColdFusion'.']" faultCode="InvokeFailed" faultDetail="Couldn't establish a connection to 'ColdFusion'"]



      I appreciate any help that can be given.
        • 1. Re: RemoteObject Error
          Michael Borbor Level 4
          You have to set up the Coldfusion destination in the remoting-config.xml inside your coldfusion installation
          • 2. Re: RemoteObject Error
            spacehog Level 1
            This is was remoting-config looks like:

            <?xml version="1.0" encoding="UTF-8"?>
            <service id="remoting-service"
            class="flex.messaging.services.RemotingService"
            messageTypes="flex.messaging.messages.RemotingMessage">

            <adapters>
            <adapter-definition id="cf-object" class="coldfusion.flash.messaging.ColdFusionAdapter" default="true"/>
            <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter"/>
            </adapters>

            <default-channels>
            <channel ref="my-cfamf"/>
            </default-channels>

            <destination id="ColdFusion">
            <channels>
            <channel ref="my-cfamf"/>
            </channels>
            <properties>
            <source>*</source>
            <!-- define the resolution rules and access level of the cfc being invoked -->
            <access>
            <!-- Use the ColdFusion mappings to find CFCs, by default only CFC files under your webroot can be found. -->
            <use-mappings>false</use-mappings>
            <!-- allow "public and remote" or just "remote" methods to be invoked -->
            <method-access-level>remote</method-access-level>
            </access>

            <property-case>
            <!-- cfc property names -->
            <force-cfc-lowercase>false</force-cfc-lowercase>
            <!-- Query column names -->
            <force-query-lowercase>false</force-query-lowercase>
            <!-- struct keys -->
            <force-struct-lowercase>false</force-struct-lowercase>
            </property-case>
            </properties>
            </destination>

            </service>
            • 3. RemoteObject Error
              Simon Bailey Level 1
              Personally for a str8 forward app such as your testing I have never had to even peek at the remoting-config file but know many people may do.

              Make sure that you have set up the Flex project to use ColdFusion and that the Flex compiler options have the correct arguments that point to your services-config file located in your CF root/WEB-INF/flex/ directory.

              Next check that the gateway is functioning correctly by entering this url (or whatever steers to your cf root) and it should return a blank white page:

              http://localhost:8501/flex2gateway/

              Lastly for your remote object source string if your flex app is NOT in your cf root try:

              source="flexclasses.cfc.testVar"

              :S
              • 4. Re: RemoteObject Error
                spacehog Level 1
                Okay, I had been creating my projects as basic projects. So I created a new project as a CF remote.

                I also changed the source to reflect the flexclasses subfolder.

                But when I go to http://localhost:8501/flex2gateway/ I get a 404 error. What is interesting is that if I go to http://localhost:8500/flex2gateway/ I get the blank page I am suppose to get. Port 8500 is my CF8 installation.

                Can I have a gateway for both CF 7and CF 8 on the same machine?
                • 5. RemoteObject Error
                  Simon Bailey Level 1
                  Bad memories coming back :) not sure on that one but recall issues, memory aint what it used to be!

                  For the mean time dude check the flex app works in the cf root that seems to be functioning correctly.
                  • 6. Re: RemoteObject Error
                    Michael Borbor Level 4
                    if I'm not wrong I think that in cf 7.02 you have to define the gateway manually. You just create an empty cfc place it in your www server root and then define and flex2gateway in the gateway configuration.
                    • 7. Re: RemoteObject Error
                      spacehog Level 1
                      Aarrrgghh!!!

                      Okay I thought I would be tricky and create a new CF project in CF8. I did that. Then I moved the cfc folder over along with the crossdomain.xml

                      So now the project is located at C:\ColdFusion8\wwwroot\testCFC\ with the testCFC.mxml file located in the src subfolder.

                      Now when I run the testCFC.mxml file I get this error:

                      [RPC Fault faultString="Unable to invoke CFC - Could not find the ColdFusion Component or Interface testVar." faultCode="Server.Processing" faultDetail="For details, turn on Robust Exception Information in the ColdFusion Administrator"]

                      The source for the RemoteObject is "testVar" because I moved the CFC into the src folder next to the testCFC.mxml file. I originally had the cfc in the 'cfc' subfolder and I got the same error message.

                      This is what my MXML file looks like now:

                      <?xml version="1.0" encoding="utf-8"?>
                      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
                      creationComplete="RO.getVar()"
                      layout="absolute">
                      <mx:RemoteObject
                      id="RO"
                      destination="ColdFusion"
                      source="testVar">

                      <mx:method name="getVar"/>

                      </mx:RemoteObject>
                      <mx:Canvas width="80%" height="80%" backgroundColor="blue" backgroundAlpha="0.17" cornerRadius="0">
                      <mx:Panel width="217" height="205" x="106.5" y="156">
                      <mx:Text text="{RO.getVar.lastResult}"/>
                      </mx:Panel>
                      </mx:Canvas>
                      </mx:Application>


                      It feels like I should be close, but there always seems to be another issue along the way.
                      • 8. Re: RemoteObject Error
                        Michael Borbor Level 4
                        now it's simpler in flex in your remote object set the source to the cfc full path from the webroot each level separated for a dot.

                        I think your source should be something like source="testCFC.src.testVar"
                        • 9. Re: RemoteObject Error
                          spacehog Level 1
                          Updated the source and I still get the same error message (updated with the new source).

                          [RPC Fault faultString="Unable to invoke CFC - Could not find the ColdFusion Component or Interface testCFC.src.testVar." faultCode="Server.Processing" faultDetail="For details, turn on Robust Exception Information in the ColdFusion Administrator"]
                          at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\3.0.x\frameworks\project s\rpc\src\mx\rpc\AbstractInvoker.as:216
                          at mx.rpc::Responder/fault()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\Responder.as:49 ]
                          at mx.rpc::AsyncRequest/fault()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\AsyncRequest .as:103]
                          at NetConnectionMessageResponder/statusHandler()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx \messaging\channels\NetConnectionChannel.as:523]
                          at mx.messaging::MessageResponder/status()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\messa ging\MessageResponder.as:222]
                          • 10. Re: RemoteObject Error
                            Simon Bailey Level 1
                            This is a perft tutorial to get things up and running, try downloading the source and seeing how you get on, just as reassurance, do a google search for you issues and you will see that so many others have has similar issues with flex and cf: http://www.adobe.com/devnet/flex/articles/helloworld.html
                            • 11. Re: RemoteObject Error
                              Michael Borbor Level 4
                              spacehog tell me where is located your cfc it should be something like c:\coldfusion8\wwwroot\testva...
                              • 12. Re: RemoteObject Error
                                spacehog Level 1
                                I'll have to look into this some more. I just tried something else for S & G. I created a new project, called testDB along with an Access database that resides in a subfolder called 'db'. The database, named 'db' is simple just one table called 'people' with a data field called 'names'.

                                I used the the CF/Flex wizard to create a simple master page that would displaythe two names in the people table.

                                When I ran the app I got the same basic error:
                                --------------------------------------------------
                                (mx.rpc::Fault)#0
                                errorID = 0
                                faultCode = "Server.Processing"
                                faultDetail = "For details, turn on Robust Exception Information in the ColdFusion Administrator"
                                faultString = "Unable to invoke CFC - Datasource dbtest could not be found."
                                message = "faultCode:Server.Processing faultString:'Unable to invoke CFC - Datasource dbtest could not be found.' faultDetail:'For details, turn on Robust Exception Information in the ColdFusion Administrator'"
                                name = "Error"
                                rootCause = (null)
                                -----------------------------------------------

                                This common "unable to invoke CFC" error is leading me to think that their is something wrong with the way my laptop is set up. I am going to try these examples on my home PC and see what happens. I have had success with the CF/Flex wizard on the home computer, so I will see what happens there.

                                BTW, I have tried the above tutorial and I always ran into errors.
                                • 13. Re: RemoteObject Error
                                  spacehog Level 1
                                  mab

                                  The cfc is currently located in the same folder as the MXML file:

                                  C:\ColdFusion8\wwwroot\testCFC\src\testVar.cfc

                                  Thanks
                                  • 14. Re: RemoteObject Error
                                    Michael Borbor Level 4
                                    Did you set up the datasource in the coldfusion administrator?
                                    • 15. Re: RemoteObject Error
                                      spacehog Level 1
                                      mab: Yes the datasource was setup.

                                      Good news! Last night I took the files home and tried them on my home PC (Dell XPS 710 with CF8 and Flexbuilder 3) and right off the bat the files work.

                                      I am going to try them on another machine in my office that I will install just CF 7.0.2 and Flex to see if that works.

                                      Not sure if there is a conflict with running both CF7 and CF 8 services together, but it looks like I will need to uninstall both versions of CF and reload.

                                      Thanks guys for all your help yesterday.