0

I've got a multi module Maven project (about 10 modules) where 2 of the modules are a flex project and its corresponding server project, communicating via BlazeDS.

The server module is dependent on another module containing common things, shared over the whole project. When using objects from the common module, the objects aren't serialized and sent via AMF to the SWF. Everything in the server-module is serialized and is working fine, but the objects from the common module (which has valid values on the server side) is not sent to the client.

I'm using Flexmojos to build this. What do I have to do to make the classes in the common project available for serialization, and being able to use them as RemoteClass-objects in my swf-project?

The basic structure is similar to this (I've tried so simplify it quite a bit):

swf-module (Flex):

Class MyObject.as:

package swf.model {

    [RemoteClass(alias="server.model.MyObject")]
    public class MyObject {
        public var name:String;
        public var common:MyCommonObject;
    }
}

Class MyCommonObject.as:

package swf.model {

    [RemoteClass(alias="common.model.MyCommonObject")]
    public class MyCommonObject {
        public var commonNumber:Number;    }
}

server-module (Java):

Class MyObject.java:

package server.model;

import common.model.MyCommonObject;

public class MyObject {
    private String name;   
    private MyCommonObject common;

    public MyObject() {}

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public MyCommonObject getCommon() {
        return common;
    }
    public void setCommon(MyCommonObject common) {
        this.common= common;
    }
}

common-module (Java)

Class MyCommonObject.java:

package common.model;

public class MyCommonObject{
    private Double commonNumber;

    public MyCommonObject() {}

    public Double getCommonNumber() {
        return commonNumber;
    }
    public void setCommonNumber(Double commonNumber) {
        this.commonNumber= commonNumber;
    }
}
thorseye
  • 237
  • 6
  • 16
  • Would you be able to share your pom.xml for this. I'm currently trying to mavenise a flex project, and facing some struggles as you did. – d-mcc-af Oct 08 '13 at 10:07
  • 1
    Sorry, can't share the pom.xml since it's containing a lot of stuff that should not be public. This specific problem was solved by not reffering to common.model.MyCommonObject in Class MyCommonObject.as. Instead, I made a subclass of common.model.MyCommonObject in server.model, and reffered to that subclass from Actionscript instead. – thorseye Oct 08 '13 at 13:24
  • Thanks for getting back to me anyway. On my long road to maven, I forget exactly what solved this problem for me, but I'm fairly sure I simply didn't have the right jars/dependencies in place. – d-mcc-af Nov 04 '13 at 16:35

3 Answers3

1

Java server side DTOs and ActionScript client DTOs are independent. I mean the following. When your BlazeDS services return AMF-serialized DTOs their binary structure is described by AMF format. And AMF transfer data contains full classpath which you describe on a client side using RemoteClass metadata. In this way client Flex project and Java server project haven't dependencies on each other in process of building. But you can build them together to produce the same WAR which contains both client and server part.

Constantiner
  • 14,231
  • 4
  • 27
  • 34
  • Ok. So I guess the problem is when the BlazeDS service is serializing the DTO. How can I debug what's going wrong when the actual AMF-serialization is happening? – thorseye Apr 29 '11 at 12:12
  • Have you any exceptions on a server side? – Constantiner Apr 29 '11 at 12:17
  • From what I can tell the server throws NO exceptions. The function that is called via a RemoteObject in Actionscript is returning a custom object, and all properties that is in the server module are sent correctly. It's only one property which is based on a class in the common module that isn't sent correctly. – thorseye Apr 29 '11 at 12:25
  • You can use tools like Charles proxy http://www.charlesproxy.com/ which supports AMF to see what exactly is transferring from server. – Constantiner Apr 29 '11 at 14:02
1

I have actually had to do this, you can go here, get the source for BlazeDS, add it to your project and debug to your heart's content.

mezmo
  • 2,441
  • 19
  • 22
0

I Think your common-module JAR is not in classpath of Flex module/WAR/BlazeDS,

try to put common module JAR in Flex modules war means PUT {common module}.jar in {BlazeDS}\WEB-INF\lib\ on deployment

if its not there.

Hopes it works

Imran
  • 2,906
  • 1
  • 19
  • 20
  • The {common.jar} is placed in {server.war}\WEB-INF\lib\{common.jar}, so I don't think that's the problem. The object is populated on the serverside but is not serialized correct. Any other ideas? – thorseye Apr 29 '11 at 12:11
  • Do you have any error on server + Are you using any custom type in DTO – Imran Apr 29 '11 at 12:18
  • (I'm writing almost the same as to Constantiner). Yes, it's a custom DTO. From what I can tell the server throws NO exceptions. The function that is called via a RemoteObject in Actionscript is returning a custom object, and all properties that is in the server module are sent correctly. It's only one property which is based on a class in the common module that isn't sent correctly. – thorseye Apr 29 '11 at 12:26
  • i am talking about custom type fields in DTO, plz share property code – Imran Apr 29 '11 at 12:31