Skip navigation
Currently Being Moderated

Problem in RPC call (flex,blazeds,spring,H2,tomcat,eclipse)

Apr 17, 2011 11:24 PM

Hi, I've problem displaying value from backend onto the flex UI. I'm using Flex,BlazeDS, Spring, H2 in my applicaiton (testdrive app).  
I've basically added another flex project to the testdrive app i downloaded. everything is working fine except the intended rpc invoke. 
pls find the code snippets for the related change below :  
  
1. FlexHelloWorld.mxml 
..... 
private function resultHandler(event:ResultEvent):void 
  

  
//used for debugging - shows details about result 
  
//returned by the Java class method 
Alert.show("success... in flex"); 
Alert.show( ObjectUtil.toString(event.result) ); 
  

...... 
<mx:RemoteObject id="ro" destination="helloServiceDestination" result="resultHandler(event)" fault="faultHandler(event)"/> 
  
  
<mx:Panel x="25" y="10" width="653" height="407" layout="vertical" title="Test Flex 3 Using Java" borderColor="#008040" fontFamily="Arial" fontWeight="bold" fontSize="13"> 
<mx:Text text="Click The Button To Test Getting Data Into Flex From A Java Class" fontWeight="bold" width="250"/> 
  <mx:Button label="Get Hello World Mesg From Java!" click="ro.getHelloWorld()"/> 
</mx:Panel> 
  
2. remoting-config.xml in flex 
<destination id="helloServiceDestination" channels="my-amf"> 
     <properties> 
         <source>org.springframework.flex.samples.example.HelloWorld</source> 
     </properties> 
  </destination> 
3. flex-servlet.xml in spring 
... 
<flex:remoting-destination ref="helloServiceDestination" /> 
... 
4. app-config.xml in spring 
.... 
<bean id="helloServiceDestination" class="org.springframework.flex.samples.example.HelloWorld">   
  </bean> 
..... 
5. HelloWorld.java 
package org.springframework.flex.samples.example; 
  
  
/** 
  * TODO Document HelloWorld 
  * <p /> 
  * 
  * @author Vinod.Jayakumar 
  */ 
public class HelloWorld { 
public String getHelloWorld(){ 
     return "HelloFromJava"; 


  
expected result : http://localhost:1977/testdrive/FlexHelloWorld.html on click of button in the screen a alert message "HelloFromJava" should be shown but i get the following error message :  
  
(mx.rpc::Fault)#0 
   content = (null) 
   errorID = 0 
   faultCode = "InvokeFailed" 
   faultDetail = "Couldn't establish a connection to 'helloServiceDestination'" 
   faultString = "[MessagingError message='Destination 'helloServiceDestination' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']" 
   message = "faultCode:InvokeFailed faultString:'[MessagingError message='Destination 'helloServiceDestination' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']' faultDetail:'Couldn't establish a connection to 'helloServiceDestination''" 
   name = "Error" 
   rootCause = (null) 
  
Request you all to provide your valuable inputs. I know there's really something silly which has gone wrong

 
Replies
  • Currently Being Moderated
    Apr 18, 2011 4:24 AM   in reply to jvk1980

    Hi jvk180:

     

    Firstly, you should either need to define the destination in remoting-config.xml or in app-context.xml, but and in both places.

     

    Secondly, the error indicates that it is missing the channel information.

     

    Option 1:

    Assuming your bean "helloServiceDestination" uses other Spring beans, then:

     

    1. The right place to declare the destinations is in app-context.xml.

    2. In that case, you need to also define the channels that the destination will be exposed over. See documentation for how to do that.

    3. In your remote object declaration, you need to pass the channel set that gets used as well.

     

    <mx:ChannelSet id="cs">

       <mx:AMFChannel url="http://<yourServerName>:<yourServerPort>:/<yourContextRoot>/messagebroker/amf "/>

    </mx:ChannelSet>

     

    <mx:RemoteObject id="ro" destination="helloServiceDestination" channelset="{cs}" result="resultHandler(event)" fault="faultHandler(event)"/>

     

    Option 2:

    If you declare your destination, in remoting-config.xml, then you need to compile your swf with services-config.xml. Refer to documentation for how to do that.

     

    Hope that helps.

    Rohit

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points