10. Troubleshooting

 Documentation Summary
 Page Summary

The Server.Acknowledge.Failed / ArgumentError Exceptions

The externalization mechanism of GraniteDS allows to keep the object strong typing on the Flex side; that is a Person object in Java will be deserialized as a Person object in AS3. That obviously implies that the model classes must be deployed in the compiled SWF. If they are not deployed, the deserialization on the Flex side will fail because it does not understand the binary externalized on the server by GraniteDS, and triggers the Server.Acknowledge.Failed or the ArgumentError exception.

Unfortunately, the mxmlc compiler includes in the SWF only the classes that are directly referenced by the MXML files (and not only imported).

Always check if all your classes are present in the SWF if your application is built with MXML files.

For example, this very simple MXML will not work:

<mx:Application>
    <mx:Script>
        import mx.controls.Alert;
        import org.granite.tide.events.TideResultEvent;
        import org.granite.tide.seam.Seam;
        import org.granite.tide.seam.Context;

        public var ctx:Context = Seam.getInstance().getSeamContext();

        private function findPerson():void {
            ctx.findPersonByName("john", findPersonResult);
        }

        private function findPersonResult(event:TideResultEvent):void {
            Alert.show("Found: " + event.result.name);
        }
    </mx:Script>
    
    <mx:Button label="Find" click="findPerson();"/>
    
</mx:Application>

This is because the Person class is not referenced anywhere in the MXML, and thus not included in the SWF by the Flex compiler. This can be fixed very easily by just changing the findPersonResult method:

import test.entity.Person;

private function findPersonResult(event:TideResultEvent):void {
    var person:Person = event.result as Person;
    Alert.show("Found: " + person.name);
}

Now the MXML depends on the Person class and the compiler will include everything in the SWF.

The more reliable workaround is to compile all the classes with compc in a SWC library and compile only the MXML files with mxmlc. Then use the -include-libraries xxx.swc mxmlc option to include your libraries in the SWF; this will force the inclusion of all the classes of the libraries in your SWF.

When using Flex Builder, it is not enough to put the libraries in the Flex build path, it is necessary to add the -include-libraries option in the Flex compiler arguments.

Browse Space

- Pages
- Blog
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

Other Features

Add Content


Copyright © 2011 Granite Data Services S.A.S. All Rights Reserved.