Flex Cairngorm Spring Blazeds - Remoting Error - help me please

2.1k views Asked by At

I seem to be getting the following error when I try to access a Remote Java class (on Spring/BlazeDS) from the Flex/Cairngorm application. I am going crazy at the moment trying to see what is wrong - any help would be greatly appreciated - thanks Mike.

**Error: C0007E: RemoteObject not found for mycomponentsService
    at RemoteObjects/getService()
    at com.adobe.cairngorm.business::ServiceLocator/getRemoteObject()
    at com.nomura.dashboard.client.business::DashBoardDelegate()**

All my config files are below:

Cairngorm - BusinessDelegate.as

this.service = ServiceLocator.getInstance().getRemoteObject("**mycomponentsService**");

Cairngorm - Services.mxml

mx:RemoteObject id="mycomponentsService" 
                destination="remotecomponentService" 
                showBusyCursor="true">

Spring/BlazeDS - application-config.xml

flex:remote-service ref="remotecomponentService" 

bean id="remotecomponentService" 
     class="com.mycompany.dashboard.server.dao.ComponentsDAO"

Spring/BlazeDS - services-config.xml

channel-definition id="myamf" class="mx.messaging.channels.AMFChannel"
endpoint url="http://localhost:8080/dashboard-server/spring/messagebroker/amf" 
class="flex.messaging.endpoints.AMFEndpoint"

The web.xml also contains Spring references - see below

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4">

<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
<display-name>dashboard-server</display-name>

<servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/*-config.xml</param-value>
    </init-param>

    <load-on-startup>1</load-on-startup>
</servlet>

<!-- Map /spring/* requests to the DispatcherServlet -->
<servlet-mapping>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <url-pattern>/spring/*</url-pattern>
    </servlet-mapping>
</web-app>
2

There are 2 answers

4
Stu Thompson On BEST ANSWER

Can we see your web.xml also please? I am surprised to see the word "spring" in the endpoint URL. My endpoints have always looked like

url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"

E.g.: I think your services-config.xml should look more like this.

    <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
         <endpoint url="http://{server.name}/dashboard-server/messagebroker/amf"
                   class="flex.messaging.endpoints.AMFEndpoint"/> 
    </channel-definition>

I would also suggest not hardcoding the end-point URL so much. Just go with

    <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
        <endpoint class="flex.messaging.endpoints.AMFEndpoint"
          url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" /> 
    </channel-definition>

Update:

OK, so your web.xml looks OK, as does having the spring in your URL. What I don's see in your Spring configuration file (application-config.xml) is the Spring URL mapping. For example, in my Spring config files, in addition to the the bean definitions, there is a mapping. E.g.:

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <value>
            /histogram/**=bean.HistogramController
            /counter/**=bean.CounterController
        </value>
    </property>
</bean>

<bean id="bean.HistogramController" class="ch.comp.app.HistogramXportController"  />
<bean id="bean.CounterController"   class="ch.comp.app.CounterXportController"    />

(I have one app that is Spring-based, and another that uses BlazeDS, but not both...so I might be missing something. That said, what I'm asking still should be valid. In theory. But take it with a grain of salt.)

Maybe some some super basic debugging is in order. Can you check to see if the calls to your server are returning HTTP 404 or not on theses problem endpoints? A couple ways to do this:

  • Check the access logs for GET /dashboard-server/spring/messagebroker/amf. What is the HTTP status code for these requests? (Free, easy, no new tools.)
  • If you are using FireFox as a browser, add the Tamper Data plug in. You don't have to tamper with the data, but it shows you what is being called, what is returned, and all the HTTP headers.
  • Use a full on Flash/Flex oriented protocol sniffer tool, like Charles Web Debugging Proxy.

It will very helpful to narrow down the problem to know if where these requests are failing on the communications stack.

3
Michael On

I have attached web.xml below. In terms of the word "Spring" - I am using the standard BlazrDS/Spring integration WAR file which requires "spring" to be there. The bean id="remotecomponentService" is acutally a Spring bean.

Are you saying even with the BlazeDS/Spring WAR I can use your solution above?

The web.xml also contains Spring references - see below

<web-app version="2.4">
<display-name>dashboard-server</display-name>
<servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/*-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<!-- Map /spring/* requests to the DispatcherServlet -->
<servlet-mapping>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <url-pattern>/spring/*</url-pattern>
    </servlet-mapping>
</web-app>