PDA

View Full Version : Exception while using the Spring+Flex package for new development



mandarbk
Jan 6th, 2009, 11:01 PM
Hi friends,

I am trying to integrate an existing Spring MVC based custom framework with flex.
1) I have simply copied the XML configuration files from Jeremy's sample application and put them in WEB-INF/flex folder of my application.The only change I made is set the default channel in services-config.xml and remoting-config.xml to "my-secure-amf" since my server accepts only "https" requests.

2) I have "/spring/*" pointing to Dispatcherservlet.

3) As part of debugging I did try to manually give a GET request to "https://{server.name}:{server.port}/{context.root}/spring/messagebroker/amfsecure".The response was 200(OK).
As per my understanding I have configured the application properly.Correct me, if i am wrong.

4) My mxml file is pretty simple,
<mx:RemoteObject id="srv" destination="product"/>

<mx:DataGrid dataProvider="{srv.getProducts.lastResult}" width="100%" height="100%"/>

<mx:Button label="Get Data" click="srv.getProducts()"/>

This is what I have configured in my Spring configuration file,
<bean id="mySpringManagedMessageBroker" class="org.springframework.flex.messaging.MessageBrokerFa ctoryBean" />
<bean id="productService" class="com.web.utility.Product"/>

<!-- Expose the productService bean for BlazeDS remoting -->
<bean id="product"
class="org.springframework.flex.messaging.remoting.FlexRe motingServiceExporter">
<property name="messageBroker" ref="mySpringManagedMessageBroker"/>
<property name="service" ref="productService"/>
</bean>

<bean class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<value>
/messagebroker/*=mySpringManagedMessageBroker
</value>
</property>
</bean>

<!-- Dispatches requests mapped to a MessageBroker -->
<bean class="org.springframework.flex.messaging.servlet.Message BrokerHandlerAdapter"/>

5) I am using Ant to generate the SWF file.

6) When I give a request to the JSP(in which flex is embedded), I get a Flash player error pop-up displaying message
[RPC Fault faultString="[MessagingError message='Destination 'product' 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 'product'"]

Can anyone help me to solve this problem?

jettro
Jan 7th, 2009, 10:56 AM
I guess this is the problem as discussed in this thread. Maybe you can try suggested solutions there.
http://forum.springframework.org/showthread.php?t=65254
success

mandarbk
Jan 8th, 2009, 11:59 PM
Thanks for your response "jettro".
I was able to resolve the issue.Strangely everything worked fine when i hardcoded endpoint URL in the services-config.xml.

jettro
Jan 9th, 2009, 12:39 AM
I see now that my response did not say much, I somehow forgot to mention the link to the item. I have added it now.

I would not recommend hard coding in config file. Gives you a hard time when deploying to other machines.