22 Replies Latest reply on Sep 13, 2010 11:40 PM by hidarikani

    TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item

    hidarikani Level 2

      I get this message printed in the CONSOLE when I debug the app.

      When I run the 'set return type wizard' valueObjects.Item gets created but when I run the app I get this Error in the console:

      TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item

        • 2. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
          hidarikani Level 2

          Hi, Flex HarUI, I've created an example project that reproduces the error that I'm facing.

           

          After running the "Connect to php" and "Configure return type" wizards I get this:

          after-configuring-return-type.png

           

          Then I select bInA() and run "generate service call" and call the service after application creationComplete.

          When running in debug mode I get this in the console:

           

          [SWF] /flexTR/VO-test-debug/Main.swf - 259,501 bytes after decompression
          [SWF] /flexTR/VO-test-debug/Main.swf/[[DYNAMIC]]/1 - 370,463 bytes after decompression
          [SWF] /flexTR/VO-test-debug/Main.swf/[[DYNAMIC]]/2 - 2,311,734 bytes after decompression
          [SWF] /flexTR/VO-test-debug/Main.swf/[[DYNAMIC]]/3 - 650,777 bytes after decompression
          [SWF] /flexTR/VO-test-debug/Main.swf/[[DYNAMIC]]/4 - 441,362 bytes after decompression
          [SWF] /flexTR/VO-test-debug/Main.swf/[[DYNAMIC]]/5 - 1,432,382 bytes after decompression
          [SWF] /flexTR/VO-test-debug/Main.swf/[[DYNAMIC]]/6 - 323,354 bytes after decompression
          TypeError: Error #1034: Type Coercion failed: cannot convert Object@73f4b51 to valueObjects.B.
          

           

          The problem:

          var a:A = bInAResult.lastResult;
          if (null == a.child)
               trace('failed to get B'); //prints this
          

           

          I have no trace() functions in my code but the error is printed in the console. I've spent two days trying to figure this one out

           

          Flex:

          <?xml version="1.0" encoding="utf-8"?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                            xmlns:s="library://ns.adobe.com/flex/spark" 
                            xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:service="services.service.*"
                            creationComplete="application1_creationCompleteHandler(event)">
               <fx:Script>
                    <![CDATA[
                         import mx.controls.Alert;
                         import mx.events.FlexEvent;
                         
                         protected function bInA():void {
                              bInAResult.token = service.bInA();
                         }
                         
          
                         protected function application1_creationCompleteHandler(event:FlexEvent):void {
                              bInA();
                         }
          
                    ]]>
               </fx:Script>
               <fx:Declarations>
                    <s:CallResponder id="bInAResult"/>
                    <service:Service id="service" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
               </fx:Declarations>
          </s:Application>
          
           
          

           

          PHP:

          <?php
               class A {
                    public $title = 'A';
                    public $child;
               }
          ?>
          <?php
               class B {
                    public $title = 'B';
               }
          ?>
          
          <?php
               require_once 'A.php';
               require_once 'B.php';
          
               class Service {
                    public function bInA() {
                         $a = new A();
                         $a->child = new B();
                         
                         return $a;
                    }
               }
          ?>
          
          • 3. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
            Flex harUI Adobe Employee

            Is that error really the last line in the console?  I would expect more

            lines to follow.

            • 4. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
              hidarikani Level 2

              Flex harUI wrote:

               

              Is that error really the last line in the console?

               

              Yes, it's the last one

               

              console.png

              Didn't have time to reply earlier

              • 6. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                Flex harUI Adobe Employee

                I think more analysis is warranted.  It looks like you are using a custom

                service.  There may be issues there.

                • 7. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                  hidarikani Level 2

                  Flex harUI wrote:

                   

                  It looks like you are using a custom service.

                   

                   

                  The service was created by 'connect to PHP' wizard

                  The value objects were created by 'configure return type' wizard

                  I didn't modify them in any way.

                   

                  The PHP code is OK because when I 'Test Operation...' I get this:

                   

                  test-operation.png

                  If it's a bug my guess it's somewhere in CallResponder

                  • 8. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                    Flex harUI Adobe Employee

                    Is valueObject.item one of the classes in the response?  Where is it used in

                    your code?

                    • 9. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                      hidarikani Level 2

                      valueObjects.Item is from a real app but it's too advanced to talk about it in a thread.

                      That's why I've created a very simple example that reproduces the error

                      and posted all of its source code in post #3.

                      The example has two value objects: A and B.

                      • 10. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                        Flex harUI Adobe Employee

                        I don't know what Test Operation is supposed to return, but it would seem

                        like the results you posted are suspicious.  I would expect the titles to

                        show a string and 'a' to show Instance of A.  You might try a example

                        project and see.

                        • 11. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                          hidarikani Level 2

                          First of all thanks for not abandoning this thread and trying to help.

                           

                          Secondly

                          I don't know what Test Operation is supposed to return, but it would seem

                          like the results you posted are suspicious.


                          You got that right. I modified the PHP objects to contain human friendlier strings:

                           

                          <?php
                               class A {
                                    public $title = 'Instance of A';
                                    public $child;
                               }
                          ?>
                          
                          <?php
                               class B {
                                    public $title = 'Instance of B';
                               }
                          ?>
                          

                           

                          I didn't change anythig else and the error remains:

                          TypeError: Error #1034: Type Coercion failed: cannot convert Object@73f4b51 to valueObjects.B.
                          
                          

                          • 12. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                            Flex harUI Adobe Employee

                            What does Test Operation show now?  If you use Test Operation on some other

                            working sample, what does it show?

                            • 14. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                              Flex harUI Adobe Employee

                              You must have an A.as and B.as somewhere.  What do they look like?

                              • 15. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                                hidarikani Level 2

                                A.as and B.as are in the valueObjects package.

                                I didn't modify files in the package in any way.

                                 

                                a-and-b.png

                                 

                                A.as:

                                /**
                                 * This is a generated sub-class of _A.as and is intended for behavior
                                 * customization.  This class is only generated when there is no file already present
                                 * at its target location.  Thus custom behavior that you add here will survive regeneration
                                 * of the super-class. 
                                 *
                                 * NOTE: Do not manually modify the RemoteClass mapping unless
                                 * your server representation of this class has changed and you've 
                                 * updated your ActionScriptGeneration,RemoteClass annotation on the
                                 * corresponding entity 
                                 **/ 
                                 
                                package valueObjects
                                {
                                
                                import com.adobe.fiber.core.model_internal;
                                
                                public class A extends _Super_A
                                {
                                    /** 
                                     * DO NOT MODIFY THIS STATIC INITIALIZER - IT IS NECESSARY
                                     * FOR PROPERLY SETTING UP THE REMOTE CLASS ALIAS FOR THIS CLASS
                                     *
                                     **/
                                     
                                    /**
                                     * Calling this static function will initialize RemoteClass aliases
                                     * for this value object as well as all of the value objects corresponding
                                     * to entities associated to this value object's entity.  
                                     */     
                                    public static function _initRemoteClassAlias() : void
                                    {
                                        _Super_A.model_internal::initRemoteClassAliasSingle(valueObjects.A);
                                        _Super_A.model_internal::initRemoteClassAliasAllRelated();
                                    }
                                     
                                    model_internal static function initRemoteClassAliasSingleChild() : void
                                    {
                                        _Super_A.model_internal::initRemoteClassAliasSingle(valueObjects.A);
                                    }
                                    
                                    {
                                        _Super_A.model_internal::initRemoteClassAliasSingle(valueObjects.A);
                                    }
                                    /** 
                                     * END OF DO NOT MODIFY SECTION
                                     *
                                     **/    
                                }
                                
                                }
                                
                                • 16. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                                  Flex harUI Adobe Employee

                                  How about Super_A and Super_B?  It may be that the classes are not

                                  registering via registerClassAlias, although sometimes the Fiber classes

                                  input ObjectProxy and convert to the classes later.

                                   

                                  You might want to try this post and see if it works for you and then

                                  compare: https://corlan.org/debugging-flex-and-php/#a3

                                  • 17. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                                    hidarikani Level 2

                                    The tutorial you posted explains how to send an array of objects.

                                    I have done that and it works fine. What is more I've successfully send A inside of A. But B in A doesn't work.

                                     

                                    _Super_A.as

                                     

                                    /**
                                     * This is a generated class and is not intended for modification.  To customize behavior
                                     * of this value object you may modify the generated sub-class of this class - A.as.
                                     */
                                    
                                    package valueObjects
                                    {
                                    import com.adobe.fiber.services.IFiberManagingService;
                                    import com.adobe.fiber.util.FiberUtils;
                                    import com.adobe.fiber.valueobjects.IValueObject;
                                    import flash.events.Event;
                                    import flash.events.EventDispatcher;
                                    import mx.binding.utils.ChangeWatcher;
                                    import mx.events.PropertyChangeEvent;
                                    import mx.validators.ValidationResult;
                                    import valueObjects.B;
                                    
                                    import flash.net.registerClassAlias;
                                    import flash.net.getClassByAlias;
                                    import com.adobe.fiber.core.model_internal;
                                    import com.adobe.fiber.valueobjects.IPropertyIterator;
                                    import com.adobe.fiber.valueobjects.AvailablePropertyIterator;
                                    
                                    use namespace model_internal;
                                    
                                    [ExcludeClass]
                                    public class _Super_A extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
                                    {
                                        model_internal static function initRemoteClassAliasSingle(cz:Class) : void
                                        {
                                            try
                                            {
                                                if (flash.net.getClassByAlias("A") == null)
                                                {
                                                    flash.net.registerClassAlias("A", cz);
                                                }
                                            }
                                            catch (e:Error)
                                            {
                                                flash.net.registerClassAlias("A", cz);
                                            }
                                        }
                                    
                                        model_internal static function initRemoteClassAliasAllRelated() : void
                                        {
                                            valueObjects.B.initRemoteClassAliasSingleChild();
                                        }
                                    
                                        model_internal var _dminternal_model : _AEntityMetadata;
                                    
                                        /**
                                         * properties
                                         */
                                        private var _internal_child : valueObjects.B;
                                        private var _internal_title : String;
                                    
                                        private static var emptyArray:Array = new Array();
                                    
                                    
                                        /**
                                         * derived property cache initialization
                                         */
                                        model_internal var _cacheInitialized_isValid:Boolean = false;
                                    
                                        model_internal var _changeWatcherArray:Array = new Array();
                                    
                                        public function _Super_A()
                                        {
                                            _model = new _AEntityMetadata(this);
                                    
                                            // Bind to own data properties for cache invalidation triggering
                                            model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "child", model_internal::setterListenerChild));
                                            model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "title", model_internal::setterListenerTitle));
                                    
                                        }
                                    
                                        /**
                                         * data property getters
                                         */
                                    
                                        [Bindable(event="propertyChange")]
                                        public function get child() : valueObjects.B
                                        {
                                            return _internal_child;
                                        }
                                    
                                        [Bindable(event="propertyChange")]
                                        public function get title() : String
                                        {
                                            return _internal_title;
                                        }
                                    
                                        /**
                                         * data property setters
                                         */
                                    
                                        public function set child(value:valueObjects.B) : void
                                        {
                                            var oldValue:valueObjects.B = _internal_child;
                                            if (oldValue !== value)
                                            {
                                                _internal_child = value;
                                                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "child", oldValue, _internal_child));
                                            }
                                        }
                                    
                                        public function set title(value:String) : void
                                        {
                                            var oldValue:String = _internal_title;
                                            if (oldValue !== value)
                                            {
                                                _internal_title = value;
                                                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "title", oldValue, _internal_title));
                                            }
                                        }
                                    
                                        /**
                                         * Data property setter listeners
                                         *
                                         * Each data property whose value affects other properties or the validity of the entity
                                         * needs to invalidate all previously calculated artifacts. These include:
                                         *  - any derived properties or constraints that reference the given data property.
                                         *  - any availability guards (variant expressions) that reference the given data property.
                                         *  - any style validations, message tokens or guards that reference the given data property.
                                         *  - the validity of the property (and the containing entity) if the given data property has a length restriction.
                                         *  - the validity of the property (and the containing entity) if the given data property is required.
                                         */
                                    
                                        model_internal function setterListenerChild(value:flash.events.Event):void
                                        {
                                            _model.invalidateDependentOnChild();
                                        }
                                    
                                        model_internal function setterListenerTitle(value:flash.events.Event):void
                                        {
                                            _model.invalidateDependentOnTitle();
                                        }
                                    
                                    
                                        /**
                                         * valid related derived properties
                                         */
                                        model_internal var _isValid : Boolean;
                                        model_internal var _invalidConstraints:Array = new Array();
                                        model_internal var _validationFailureMessages:Array = new Array();
                                    
                                        /**
                                         * derived property calculators
                                         */
                                    
                                        /**
                                         * isValid calculator
                                         */
                                        model_internal function calculateIsValid():Boolean
                                        {
                                            var violatedConsts:Array = new Array();
                                            var validationFailureMessages:Array = new Array();
                                    
                                            var propertyValidity:Boolean = true;
                                            if (!_model.childIsValid)
                                            {
                                                propertyValidity = false;
                                                com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_childValidationFailureMessages);
                                            }
                                            if (!_model.titleIsValid)
                                            {
                                                propertyValidity = false;
                                                com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_titleValidationFailureMessages);
                                            }
                                    
                                            model_internal::_cacheInitialized_isValid = true;
                                            model_internal::invalidConstraints_der = violatedConsts;
                                            model_internal::validationFailureMessages_der = validationFailureMessages;
                                            return violatedConsts.length == 0 && propertyValidity;
                                        }
                                    
                                        /**
                                         * derived property setters
                                         */
                                    
                                        model_internal function set isValid_der(value:Boolean) : void
                                        {
                                            var oldValue:Boolean = model_internal::_isValid;
                                            if (oldValue !== value)
                                            {
                                                model_internal::_isValid = value;
                                                _model.model_internal::fireChangeEvent("isValid", oldValue, model_internal::_isValid);
                                            }
                                        }
                                    
                                        /**
                                         * derived property getters
                                         */
                                    
                                        [Transient]
                                        [Bindable(event="propertyChange")]
                                        public function get _model() : _AEntityMetadata
                                        {
                                            return model_internal::_dminternal_model;
                                        }
                                    
                                        public function set _model(value : _AEntityMetadata) : void
                                        {
                                            var oldValue : _AEntityMetadata = model_internal::_dminternal_model;
                                            if (oldValue !== value)
                                            {
                                                model_internal::_dminternal_model = value;
                                                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "_model", oldValue, model_internal::_dminternal_model));
                                            }
                                        }
                                    
                                        /**
                                         * methods
                                         */
                                    
                                    
                                        /**
                                         *  services
                                         */
                                        private var _managingService:com.adobe.fiber.services.IFiberManagingService;
                                    
                                        public function set managingService(managingService:com.adobe.fiber.services.IFiberManagingService):void
                                        {
                                            _managingService = managingService;
                                        }
                                    
                                        model_internal function set invalidConstraints_der(value:Array) : void
                                        {
                                            var oldValue:Array = model_internal::_invalidConstraints;
                                            // avoid firing the event when old and new value are different empty arrays
                                            if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
                                            {
                                                model_internal::_invalidConstraints = value;
                                                _model.model_internal::fireChangeEvent("invalidConstraints", oldValue, model_internal::_invalidConstraints);
                                            }
                                        }
                                    
                                        model_internal function set validationFailureMessages_der(value:Array) : void
                                        {
                                            var oldValue:Array = model_internal::_validationFailureMessages;
                                            // avoid firing the event when old and new value are different empty arrays
                                            if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
                                            {
                                                model_internal::_validationFailureMessages = value;
                                                _model.model_internal::fireChangeEvent("validationFailureMessages", oldValue, model_internal::_validationFailureMessages);
                                            }
                                        }
                                    
                                        model_internal var _doValidationCacheOfChild : Array = null;
                                        model_internal var _doValidationLastValOfChild : valueObjects.B;
                                    
                                        model_internal function _doValidationForChild(valueIn:Object):Array
                                        {
                                            var value : valueObjects.B = valueIn as valueObjects.B;
                                    
                                            if (model_internal::_doValidationCacheOfChild != null && model_internal::_doValidationLastValOfChild == value)
                                               return model_internal::_doValidationCacheOfChild ;
                                    
                                            _model.model_internal::_childIsValidCacheInitialized = true;
                                            var validationFailures:Array = new Array();
                                            var errorMessage:String;
                                            var failure:Boolean;
                                    
                                            var valRes:ValidationResult;
                                            if (_model.isChildAvailable && _internal_child == null)
                                            {
                                                validationFailures.push(new ValidationResult(true, "", "", "child is required"));
                                            }
                                    
                                            model_internal::_doValidationCacheOfChild = validationFailures;
                                            model_internal::_doValidationLastValOfChild = value;
                                    
                                            return validationFailures;
                                        }
                                        
                                        model_internal var _doValidationCacheOfTitle : Array = null;
                                        model_internal var _doValidationLastValOfTitle : String;
                                    
                                        model_internal function _doValidationForTitle(valueIn:Object):Array
                                        {
                                            var value : String = valueIn as String;
                                    
                                            if (model_internal::_doValidationCacheOfTitle != null && model_internal::_doValidationLastValOfTitle == value)
                                               return model_internal::_doValidationCacheOfTitle ;
                                    
                                            _model.model_internal::_titleIsValidCacheInitialized = true;
                                            var validationFailures:Array = new Array();
                                            var errorMessage:String;
                                            var failure:Boolean;
                                    
                                            var valRes:ValidationResult;
                                            if (_model.isTitleAvailable && _internal_title == null)
                                            {
                                                validationFailures.push(new ValidationResult(true, "", "", "title is required"));
                                            }
                                    
                                            model_internal::_doValidationCacheOfTitle = validationFailures;
                                            model_internal::_doValidationLastValOfTitle = value;
                                    
                                            return validationFailures;
                                        }
                                        
                                    
                                    }
                                    
                                    }
                                    
                                     
                                    

                                     

                                     

                                    _Super_B.as

                                    /**
                                     * This is a generated class and is not intended for modification.  To customize behavior
                                     * of this value object you may modify the generated sub-class of this class - B.as.
                                     */
                                    
                                    package valueObjects
                                    {
                                    import com.adobe.fiber.services.IFiberManagingService;
                                    import com.adobe.fiber.util.FiberUtils;
                                    import com.adobe.fiber.valueobjects.IValueObject;
                                    import flash.events.Event;
                                    import flash.events.EventDispatcher;
                                    import mx.binding.utils.ChangeWatcher;
                                    import mx.events.PropertyChangeEvent;
                                    import mx.validators.ValidationResult;
                                    
                                    import flash.net.registerClassAlias;
                                    import flash.net.getClassByAlias;
                                    import com.adobe.fiber.core.model_internal;
                                    import com.adobe.fiber.valueobjects.IPropertyIterator;
                                    import com.adobe.fiber.valueobjects.AvailablePropertyIterator;
                                    
                                    use namespace model_internal;
                                    
                                    [ExcludeClass]
                                    public class _Super_B extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
                                    {
                                        model_internal static function initRemoteClassAliasSingle(cz:Class) : void
                                        {
                                            try
                                            {
                                                if (flash.net.getClassByAlias("B") == null)
                                                {
                                                    flash.net.registerClassAlias("B", cz);
                                                }
                                            }
                                            catch (e:Error)
                                            {
                                                flash.net.registerClassAlias("B", cz);
                                            }
                                        }
                                    
                                        model_internal static function initRemoteClassAliasAllRelated() : void
                                        {
                                        }
                                    
                                        model_internal var _dminternal_model : _BEntityMetadata;
                                    
                                        /**
                                         * properties
                                         */
                                        private var _internal_title : String;
                                    
                                        private static var emptyArray:Array = new Array();
                                    
                                    
                                        /**
                                         * derived property cache initialization
                                         */
                                        model_internal var _cacheInitialized_isValid:Boolean = false;
                                    
                                        model_internal var _changeWatcherArray:Array = new Array();
                                    
                                        public function _Super_B()
                                        {
                                            _model = new _BEntityMetadata(this);
                                    
                                            // Bind to own data properties for cache invalidation triggering
                                            model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "title", model_internal::setterListenerTitle));
                                    
                                        }
                                    
                                        /**
                                         * data property getters
                                         */
                                    
                                        [Bindable(event="propertyChange")]
                                        public function get title() : String
                                        {
                                            return _internal_title;
                                        }
                                    
                                        /**
                                         * data property setters
                                         */
                                    
                                        public function set title(value:String) : void
                                        {
                                            var oldValue:String = _internal_title;
                                            if (oldValue !== value)
                                            {
                                                _internal_title = value;
                                                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "title", oldValue, _internal_title));
                                            }
                                        }
                                    
                                        /**
                                         * Data property setter listeners
                                         *
                                         * Each data property whose value affects other properties or the validity of the entity
                                         * needs to invalidate all previously calculated artifacts. These include:
                                         *  - any derived properties or constraints that reference the given data property.
                                         *  - any availability guards (variant expressions) that reference the given data property.
                                         *  - any style validations, message tokens or guards that reference the given data property.
                                         *  - the validity of the property (and the containing entity) if the given data property has a length restriction.
                                         *  - the validity of the property (and the containing entity) if the given data property is required.
                                         */
                                    
                                        model_internal function setterListenerTitle(value:flash.events.Event):void
                                        {
                                            _model.invalidateDependentOnTitle();
                                        }
                                    
                                    
                                        /**
                                         * valid related derived properties
                                         */
                                        model_internal var _isValid : Boolean;
                                        model_internal var _invalidConstraints:Array = new Array();
                                        model_internal var _validationFailureMessages:Array = new Array();
                                    
                                        /**
                                         * derived property calculators
                                         */
                                    
                                        /**
                                         * isValid calculator
                                         */
                                        model_internal function calculateIsValid():Boolean
                                        {
                                            var violatedConsts:Array = new Array();
                                            var validationFailureMessages:Array = new Array();
                                    
                                            var propertyValidity:Boolean = true;
                                            if (!_model.titleIsValid)
                                            {
                                                propertyValidity = false;
                                                com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_titleValidationFailureMessages);
                                            }
                                    
                                            model_internal::_cacheInitialized_isValid = true;
                                            model_internal::invalidConstraints_der = violatedConsts;
                                            model_internal::validationFailureMessages_der = validationFailureMessages;
                                            return violatedConsts.length == 0 && propertyValidity;
                                        }
                                    
                                        /**
                                         * derived property setters
                                         */
                                    
                                        model_internal function set isValid_der(value:Boolean) : void
                                        {
                                            var oldValue:Boolean = model_internal::_isValid;
                                            if (oldValue !== value)
                                            {
                                                model_internal::_isValid = value;
                                                _model.model_internal::fireChangeEvent("isValid", oldValue, model_internal::_isValid);
                                            }
                                        }
                                    
                                        /**
                                         * derived property getters
                                         */
                                    
                                        [Transient]
                                        [Bindable(event="propertyChange")]
                                        public function get _model() : _BEntityMetadata
                                        {
                                            return model_internal::_dminternal_model;
                                        }
                                    
                                        public function set _model(value : _BEntityMetadata) : void
                                        {
                                            var oldValue : _BEntityMetadata = model_internal::_dminternal_model;
                                            if (oldValue !== value)
                                            {
                                                model_internal::_dminternal_model = value;
                                                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "_model", oldValue, model_internal::_dminternal_model));
                                            }
                                        }
                                    
                                        /**
                                         * methods
                                         */
                                    
                                    
                                        /**
                                         *  services
                                         */
                                        private var _managingService:com.adobe.fiber.services.IFiberManagingService;
                                    
                                        public function set managingService(managingService:com.adobe.fiber.services.IFiberManagingService):void
                                        {
                                            _managingService = managingService;
                                        }
                                    
                                        model_internal function set invalidConstraints_der(value:Array) : void
                                        {
                                            var oldValue:Array = model_internal::_invalidConstraints;
                                            // avoid firing the event when old and new value are different empty arrays
                                            if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
                                            {
                                                model_internal::_invalidConstraints = value;
                                                _model.model_internal::fireChangeEvent("invalidConstraints", oldValue, model_internal::_invalidConstraints);
                                            }
                                        }
                                    
                                        model_internal function set validationFailureMessages_der(value:Array) : void
                                        {
                                            var oldValue:Array = model_internal::_validationFailureMessages;
                                            // avoid firing the event when old and new value are different empty arrays
                                            if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
                                            {
                                                model_internal::_validationFailureMessages = value;
                                                _model.model_internal::fireChangeEvent("validationFailureMessages", oldValue, model_internal::_validationFailureMessages);
                                            }
                                        }
                                    
                                        model_internal var _doValidationCacheOfTitle : Array = null;
                                        model_internal var _doValidationLastValOfTitle : String;
                                    
                                        model_internal function _doValidationForTitle(valueIn:Object):Array
                                        {
                                            var value : String = valueIn as String;
                                    
                                            if (model_internal::_doValidationCacheOfTitle != null && model_internal::_doValidationLastValOfTitle == value)
                                               return model_internal::_doValidationCacheOfTitle ;
                                    
                                            _model.model_internal::_titleIsValidCacheInitialized = true;
                                            var validationFailures:Array = new Array();
                                            var errorMessage:String;
                                            var failure:Boolean;
                                    
                                            var valRes:ValidationResult;
                                            if (_model.isTitleAvailable && _internal_title == null)
                                            {
                                                validationFailures.push(new ValidationResult(true, "", "", "title is required"));
                                            }
                                    
                                            model_internal::_doValidationCacheOfTitle = validationFailures;
                                            model_internal::_doValidationLastValOfTitle = value;
                                    
                                            return validationFailures;
                                        }
                                        
                                    
                                    }
                                    
                                    }
                                    
                                     
                                    
                                    • 18. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                                      Flex harUI Adobe Employee

                                      "A in B" or "B in A"?  I think this class is set up for B as a sub-object of

                                      A which I think is how your test operation results indicated.  You might try

                                      seeing if the registration code is running (where it calls

                                      registerClassAlias).

                                       

                                      Since you got A in A working, you might try that configuration, set a

                                      breakpoint in the Super_A constructor and see where that gets instantiated

                                      then compare that code path for B in A.

                                       

                                      I don't know anything about PHP, but is there any way you can specify the

                                      type of the child property in php class for A?

                                      • 19. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                                        hidarikani Level 2

                                        "A in B" or "B in A"?

                                        B in A

                                        You might try seeing if the registration code is running (where it calls registerClassAlias).

                                         

                                        The constructor of _Super_B.as which contains a call to registerClassAlias never runs (The error is printed to the console before it has a chance to run).

                                         

                                        I've set a breakpoint on line:

                                         

                                        bInAResult.token = service.bInA();
                                        
                                        

                                         

                                        in Main.mxml (the service passess something to the CallResponder).

                                        I kept pressing F6 until I got this:

                                         

                                        debug.png

                                         

                                        When I reach this line in AbstactMessage.as the error is printed to the console:

                                        TypeError: Error #1034: Type Coercion failed: cannot convert Object@6f17c89 to valueObjects.B.
                                        

                                        But I don't understant how to interprit these results.

                                         

                                        Is there any way you can specify the

                                        type of the child property in php class for A?

                                        From PHP documentation:

                                        "PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which the variable is used. That is to say, if a string value is assigned to variable $var, $var becomes a string. If an integer value is then assigned to $var, it becomes an integer."

                                        • 20. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                                          Flex harUI Adobe Employee

                                          I would definitely go back to the "A in A" scenario and see if/when the

                                          registerClassAlias for A is called (if at all) and when the constructors for

                                          A/Super_A are called.  The service decoder for XML doesn't call the

                                          registration code.  Maybe the PHP decoder doesn't either.  In XML the

                                          constructors are called in a later conversion phase.

                                           

                                          Then I would set breakpoints at various places in the call stack that you

                                          saw when the classes get registered or constructed and compare the code

                                          paths taken when you switch back to "B in A".

                                          • 21. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                                            mr_tijn

                                            We may have seen a similar issue. The problem was that in the generated services as file,

                                            not all _initRemoteClassAlias initializers were called.

                                             

                                            Note that this was only on my colleagues FB4.0.1 version.

                                            The code generated in my own FB4.0.0 works correctly.

                                             

                                            Can you check whether both valueObjects.A._initRemoteClassAlias() and valueObjects.B._initRemoteClassAlias()

                                            are in your generated service file ?

                                            • 22. Re: TypeError: Error #1034: Type Coercion failed: cannot convert Object@6802059 to valueObjects.Item
                                              hidarikani Level 2

                                              Will try the proposed solutions and post results next week.