Skip navigation
Currently Being Moderated

Problems using BlazeDS and actionscript (no Flex)

Aug 20, 2008 7:44 AM

Hopefully somebody here can help - I've been going around in circles for a couple of days now.

I'm trying to preform a RemoteObject invocation again BlazeDS. I've seen many examples that allegedly work but I just cant get it to. I'm using Flex 3 SDK and recommended turnkey build.

When I execute this client code (I've omitted the event handler functions):

var swfURL:String = this.loaderInfo.url;
LoaderConfig.mx_internal::_url = this.loaderInfo.url;
LoaderConfig.mx_internal::_parameters = this.loaderInfo.parameters;

var amfChannel:AMFChannel = new AMFChannel(null, "http://localhost:8400/hello/messagebroker/amf");
amfChannel.requestTimeout = 3;
amfChannel.connectTimeout = 3;
var channelSet:ChannelSet = new ChannelSet();
channelSet.addChannel( amfChannel );

amfChannel.addEventListener(ChannelFaultEvent.FAULT, handleChannelFault);
amfChannel.addEventListener(ChannelEvent.CONNECT, handleChannelConnect);
amfChannel.addEventListener(ChannelEvent.DISCONNECT, handleChannelDisconnect);

ro = new RemoteObject();
ro.destination = "Hello";
ro.channelSet = channelSet;
ro.addEventListener(ResultEvent.RESULT, onResult);
ro.addEventListener(FaultEvent.FAULT, onFault);
ro.getOperation("sayHello").send();

I get this on the client side:
TypeError: Error #1034: Type Coercion failed: cannot convert Object@13e9921 to mx.messaging.messages.ErrorMessage.

The error event on the client says:
rootCause = (mx.messaging.events::ChannelFaultEvent)#3

On the server I get this logging:

[BlazeDS] FlexSession created with id '773A4F225C1C65663B09BB8DD3E35334' for an
Http-based client connection.
[BlazeDS] Channel endpoint hello-amf received request.
[BlazeDS] Deserializing AMF/HTTP request
Version: 3
(Message #0 targetURI=null, responseURI=/1)
(Array #0)
[0] = (Object #0)
operation = 5
correlationId = ""
timeToLive = 0
timestamp = 0
destination = ""
headers = (Object #1)
DSMessagingVersion = 1
DSId = "nil"
clientId = null
messageId = "2CAC2BEC-4C0F-AE41-12DD-E0C5824EF4D3"
body = (Object #2)

[BlazeDS] Serializing AMF/HTTP response
Version: 3
(Header #0 name=AppendToGatewayUrl, mustUnderstand=false)
";jsessionid=773A4F225C1C65663B09BB8DD3E35334"

(Message #0 targetURI=/1/onStatus, responseURI=)
(Object #0)
code = "Server.Processing"
rootCause = null
message = "No destination with id 'null' is registered with any service."
details = null

[BlazeDS] FlexSession with id 'A66B450C6CDA5EB573942ECA2FA6C978' for an Http-based client connection has been invalidated.

You can see it says seems to think the destination = null but it is being set in the client code....

Any help will be greatly appreciated!
 
Replies
  • Currently Being Moderated
    Aug 20, 2008 9:16 AM   in reply to (Richard_Jewson)
    I think one problem is that the various mx.messaging.messages.Message
    implementations have not called flash.net.registerClassAlias() for each
    of their types. In Flex, the compiler notices the [RemoteClass] metadata
    on each ActionScript class and codegens static initializer code to call
    flash.net.registerClassAlias() while the application is initializing (so
    that it occurs before any data is sent or received).

    Note you can see this generated code if you specify
    -keep-generated-actionscript=true on the command line arguments for
    mxmlc. For compiling a file called test.mxml, find the
    /generated/_test_FlexInit-generated.as file and notice the calls to
    flash.net.registerClassAlias.


    For example, in the pure ActionScript case, you may need to call the
    following before making any calls?


    import mx.messaging.messages.*;
    import mx.messaging.config.ConfigMap;
    import mx.collections.ArrayList;
    import mx.collections.ArrayCollection;
    import mx.utils.ObjectProxy;

    ...

    flash.net.registerClassAlias("flex.messaging.messages.CommandMessage",
    CommandMessage);
    flash.net.registerClassAlias("flex.messaging.messages.RemotingMessage" ,
    RemotingMessage);
    flash.net.registerClassAlias("flex.messaging.messages.AcknowledgeMessa ge
    ", AcknowledgeMessage);
    flash.net.registerClassAlias("flex.messaging.messages.ErrorMessage",
    ErrorMessage);
    flash.net.registerClassAlias("DSC", CommandMessageExt);
    flash.net.registerClassAlias("DSK", AcknowledgeMessageExt);
    flash.net.registerClassAlias("flex.messaging.io.ArrayList", ArrayList);
    flash.net.registerClassAlias("flex.messaging.config.ConfigMap",
    ConfigMap);
    flash.net.registerClassAlias("flex.messaging.io.ArrayCollection",
    ArrayCollection);
    flash.net.registerClassAlias("flex.messaging.io.ObjectProxy",
    ObjectProxy);

    // You may want to register pub/sub and other rpc message types too...
    flash.net.registerClassAlias("flex.messaging.messages.HTTPMessage",
    HTTPRequestMessage);
    flash.net.registerClassAlias("flex.messaging.messages.SOAPMessage",
    SOAPMessage);
    flash.net.registerClassAlias("flex.messaging.messages.AsyncMessage",
    AsyncMessage);
    flash.net.registerClassAlias("DSA", AsyncMessageExt);
    flash.net.registerClassAlias("flex.messaging.messages.MessagePerforman ce
    Info", MessagePerformanceInfo);


    Pete
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 27, 2011 5:31 AM   in reply to Peter Farland

    Thanks. This helped us fix "TypeError: Error #1034: Type Coercion failed: cannot convert Object mx.messaging.messages.AcknowledgeMessageExt". We had to add in Main.mxml

     

    try {

          if (flash.net.getClassByAlias("com.javapkgnm.vo.SomeVO") == null){

              flash.net.registerClassAlias("com.javapkgnm.vo.SomeVO", com.flexpkgnm.vo.SomeVO);}

          } catch (e:Error) {

              flash.net.registerClassAlias("com.javapkgnm.vo.SomeVO", com.flexpkgnm.vo.SomeVO); }

     

    - vineet

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 13, 2012 7:47 AM   in reply to Peter Farland

    Thanks alot. This helped me to  fix "TypeError: Error #1034: Type Coercion failed: cannot convert Object to mx.messaging.messages.Imessage.

     

    - Aditya Velala

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)