Announcement Announcement Module
Collapse
No announcement yet.
Flex 4 Blazeds Java Integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Flex 4 Blazeds Java Integration

    I'm having a problem calling Java services via Flex BlazeDS.

    I'm using Spring 3.0.5 with Annotations and Flex 1.0.3.

    I've created a POJO as "Group" with public attributes, and I have a AS4 "Group" class with the same attributes.

    I setup my RemoteObject as so:


    Code:
    public static function getRemoteObject(destination:String, event:Function, error:Function, showBusyCursor:Boolean=false):RemoteObject {
    
    	var cs:ChannelSet = new ChannelSet();
    	
    	var amfChannel:AMFChannel = new AMFChannel("my-amf", "messagebroker/amf");
    	cs.addChannel(amfChannel);
    
    	var service:RemoteObject = new RemoteObject();
    	service.channelSet = cs;
    	service.destination = destination;
    	service.showBusyCursor = showBusyCursor;
    	
    	service.addEventListener(ResultEvent.RESULT, event);
    	service.addEventListener(FaultEvent.FAULT, error);
    	
    	return service;
    }
    and call this from my modules as:

    Code:
    var grp:Group = new Group();
    ... load group
    var service:RemoteObject = RemoteCalls.getRemoteObject("GroupDAO", resultHandler, faultHandler);
    service.createGroup(grp);
    This works without a problem, but if I call another service from the same bean, Flex/BlazeDS doesn't seem to be able to map the Flex Group object to the POJO.

    I've listed the BlazeDS logs for a successful request and a failed request. Both services work, but I can only use one of them as many times as I want, but the other will not work until I reload the Flex App.




    Successful:
    [BlazeDS]Serializing AMF/HTTP response
    Version: 3
    (Message #0 targetURI=/2/onResult, responseURI=)
    (Externalizable Object #0 'DSK')
    (Externalizable Object #1 'flex.messaging.io.ArrayCollection')
    (Array #2)
    [0] = (Typed Object #3 'com.group.entity.Group')
    appId = 14
    admin = 0
    userId = null
    name = "All"
    cmnt = ""
    updateId = ""
    type = 1
    updateDate = "2011-02-13 19:04:26.0"
    grpId = 22
    [1] = (Typed Object #4 'com.group.entity.Group')
    appId = 14
    admin = 0
    userId = null
    name = "Junk"
    cmnt = ""
    updateId = ""
    type = 1
    updateDate = "2011-02-15 21:16:16.0"
    grpId = 28
    [2] = (Typed Object #5 'com.group.entity.Group')
    appId = 14
    admin = 0
    userId = null
    name = "TEST5"
    cmnt = null
    updateId = ""
    type = 2
    updateDate = "2011-02-04 08:41:23.0"
    grpId = 21
    1.297822576209E12


    Failed
    [BlazeDS]Deserializing AMF/HTTP request
    Version: 3
    (Message #0 targetURI=null, responseURI=/2)
    (Array #0)
    [0] = (Typed Object #0 'flex.messaging.messages.RemotingMessage')
    source = null
    operation = "createUserLinkedGroup"
    timestamp = 0
    headers = (Object #1)
    DSId = "BA0A04ED-B518-B539-8D32-D2B0229B6A6A"
    DSEndpoint = "my-amf"
    destination = "GroupDao"
    body = (Array #2)
    [0] = (Object #3)
    name = null
    updateDate = null
    grpId = 28
    appId = 14
    userId = ""
    type = 0
    cmnt = null
    admin = 2
    updateId = null
    clientId = null
    messageId = "3AA0A73A-DA80-0AE0-FD86-2C42AF0AEEEC"
    timeToLive = 0

    [BlazeDS]Serializing AMF/HTTP response
    Version: 3
    (Message #0 targetURI=/2/onStatus, responseURI=)
    (Typed Object #0 'flex.messaging.messages.ErrorMessage')
    headers = (Object #1)
    rootCause = (Typed Object #2 'flex.messaging.messages.ErrorMessage')
    headers = (Object #3)
    rootCause = null
    body = null
    correlationId = null
    faultDetail = null
    faultString = "Cannot convert type flex.messaging.io.amf.ASObject with remote type specified as 'null' to an instance of class com.group.entity.Group"
    clientId = null
    timeToLive = 0.0
    destination = null
    timestamp = 1.29782269116E12
    extendedData = null
    faultCode = "Client.Message.Deserialize.InvalidType"
    messageId = "BA0ECE15-D82F-FB38-C928-A17D37B02453"
    body = null
    correlationId = "3AA0A73A-DA80-0AE0-FD86-2C42AF0AEEEC"
    faultDetail = "The expected argument types are (com.group.entity.Group) but the supplied types were (flex.messaging.io.amf.ASObject) and converted to (null)."
    faultString = "Cannot invoke method 'createUserLinkedGroup'."
    clientId = "BA0ECE15-D80A-19E2-936E-ACB39CA25F34"
    timeToLive = 0.0
    destination = "GroupDao"
    timestamp = 1.29782269116E12
    extendedData = null
    faultCode = "Server.ResourceUnavailable"
    messageId = "BA0ECE15-D819-513C-E9CD-9850697CD5C1"


    As you can see from the logs, in the successful transactions the correct 'Group' object was used, but in the failed, its unable to locate the correct object to pass.

    Any ideas of where I need to look to understand what I am doing wrong ?

    Could this issue be related to the Spring Annotations?

    I tried changing my definitions from:
    Code:
    @Repository("GroupDao")
    @RemotingDestination
    public class GroupDaoImpl implements GroupDao {
    to:

    Code:
    @Service("GroupDao")
    @RemotingDestination
    public class GroupDaoImpl implements GroupDao {
    and now neither of the services will map to the typed Object and I get the same error returned:

    faultString = “Cannot convert type flex.messaging.io.amf.ASObject with remote type specified as ‘null’ to an instance of class com.group.entity.Group”



    Thanks
    Last edited by StaticSpace; Feb 16th, 2011, 08:11 AM. Reason: Update with new findings

  • #2
    That error indicates that you are doing something wrong on the Flex side, though I've not seen enough of your code to say for certain what is wrong. Have you specified the [RemoteClass] metadata properly on all of your objects?

    One thing that's a little strange is that you are recreating the ChannelSet every time you create your RemoteObject. You should only need to have a single instance of ChannelSet that gets reused for each new RemoteObject.

    Comment


    • #3
      Yes, they are defined as below.
      Code:
      [RemoteClass(alias="com.group.entity.Group")]
      public class Group {...
      I will adjust the code to reuse the channelset, thanks for that tip.

      Other than that, I'm still lost here. I've tried many different ways on these classes, from private vars with getters and setters to public vars, I've tried implmenting serializable for the POJOs, but I just can't seem to find where the problem is.

      I'm still thinking it may be a Spring Annotation issue, because the services should work when I change the @Repository to @Service, but they won't map the typed beans, they only seem to except standard objects like String.

      Comment


      • #4
        Originally posted by StaticSpace View Post
        I'm still thinking it may be a Spring Annotation issue, because the services should work when I change the @Repository to @Service, but they won't map the typed beans, they only seem to except standard objects like String.
        I really don't see how that could be the case. The logs you posted clearly show that the AMF message is being sent from the Flex client without the necessary type mapping information. The deserialization to the appropriately typed object on the Java side happens well before the call gets routed to the given Spring bean.

        Comment


        • #5
          A good solution

          I found an answer that can be good for your problem and for other people that have the same problem...

          http://www.flexdeveloper.eu/forums/m...-argument-typ/

          For me, it works!

          Comment

          Working...
          X