2 Replies Latest reply on Sep 16, 2009 12:26 AM by jake_flex

    BlazeDS: Cannot call remote object

    jake_flex Level 2

      I get the following error in Flex when calling a remote java object

       

      [RPC Fault faultString="[MessagingError message='Destination 'pojo' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']" faultCode="InvokeFailed" faultDetail="Couldn't establish a connection to 'pojo'"]
           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 Function/http://adobe.com/AS3/2006/builtin::apply()
           at mx.rpc::AbstractService/http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()
           at main/___main_Button1_click()
      

       

      The flex code is very simple and seen below

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:RemoteObject id="myPojo" destination="pojo" />
      <mx:Button click="myPojo.sayHello()" label="pojo call"/>     
      </mx:Application>
      

      And the Java class

      package blaze1.pojo;
      
      public class MyPojo 
      {
           public MyPojo()
           {
           
           }
      
           public String sayHello()
           {
                return "Hello flex";
           }
      
      }
      
      

      I have also attached the blazeDS configuration files.

       

      I have the java class packed in a jar in WEB-INF/lib. Do I have to define the jar file name somewhere in the conf files?

       

      After solving the issues with MessageBroker, the Tomcat logs don't show any errors.

       

      Thanks.

        • 1. Re: BlazeDS: Cannot call remote object
          paul.williams Level 4

          Have you added the mxmlc "services" compiler option when you build in Flex Builder:

           

          http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postI d=12209

           

          If so, there are a few things you could do to troubleshoot:

           

          1) Rather than using a jar, place your compiled classes under WEB-INF/classes. So your pojo class would be at:

           

               WEB-INF/classes/blaze1/pojo/MyPojo.class

           

               Try running your application again.

           

          2) Seach the log output from Tomcat for any errors during startup or when you try to hit your remote object. You can increase the log-level of the BlazeDS components by editing the 'logging' element of services-config.xml.

           

          3) To test your jar file structure, run the following command on your jar file:

           

               javap -classpath <path-to-your-web-app>/WEB-INF/lib/myclasses.jar  blaze1.pojo.MyPojo

           

               It should print the api of your MyPojo class if your jar is built correctly.

          1 person found this helpful
          • 2. Re: BlazeDS: Cannot call remote object
            jake_flex Level 2

            Thanks for the reply p_m_williams,

             

            Adding the services compiler option fixed the issue. I'm using ant for building, so mxmlc task needed services and context-root attributes. Like this

             

            <mxmlc 
                         file="src/blaze1/flex/main.mxml" 
                         output="${build-dir}/flex/main.swf"
                         services="WebContent/WEB-INF/flex/services-config.xml"
                         context-root="/blaze1"
                         >
                             <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
                             <source-path path-element="${FLEX_HOME}/frameworks" />
                             
                             <!-- List of SWC files or directories that contain SWC files. --> 
                             <compiler.library-path dir="${FLEX_HOME}/frameworks" append="true"> <!-- Core libs --> 
                                 <include name="libs" /> 
                                 <include name="../bundles/{locale}" /> 
                             </compiler.library-path>
                         </mxmlc>
            

            The services attribute points to the services-config.xml as seen and context-root is the web app root context, which in this case is /blaze1

             

            I also added the following line to the flex code to get the results from the remote object call.

            <mx:Label text="{myPojo.sayHello.lastResult}" />