10 Replies Latest reply on Feb 14, 2012 3:56 PM by arie6

    Problem when using marshall plan

    akhilagrawal

      We are using two versions of ILog (2.5 for Gantt Chart and 3.0 for  Timeline Chart). The two versions conflict with each other, so I have  used Marshall plan for resolving the  conflict.

      I am loading the ILog 3.0 Timeline Chart  as a separate swf using swf loader with loadForCompatibility as true.  This basically loads the TimelineChart in a sibling application domain  which avoids the namespace and class conflicts. In the main application we are using Ilog 2.5 Gantt chart.

      Now things are working properly and I am able to pass data to the  Timeline Chart from the main application using SwfBridgeEvent (which has  to marshaled in the timeline swf using marshal function). Only the  flash player classes are shared among the two domains, so the data  cannot be passed as typed objects, instead I had to pass the data by  encoding the typed object collection into xml string. This all is working  fine.

      There is only one problem which occurs sometimes is the Type  Coercion errors like ArrayCollection@ cannot be cast to ArrayCollection.  This problem is not consistent as it doesn't occur many a times. I was  trying to find any pattern or something but couldn't.

       

      Any help on possible reason or solution.

        • 1. Re: Problem when using marshall plan
          Flex harUI Adobe Employee

          What is the full stack dump when that happens?

          • 2. Re: Problem when using marshall plan
            akhilagrawal Level 1

            We are using Cairngorm 2 and Flex Remoting. Type coercion error is always occurring only when the data from server is being deserialized.

             

            Stack trace 1

             

            file:/E:/Akhil/Projects/PlantMaintenance/bin-debug/PlantMaintenance.html  

             

                Main Thread (Suspended: TypeError: Error #1034: Type Coercion failed: cannot convert mx.collections::ArrayCollection@207d35c1 to mx.collections.ArrayCollection.)  

             

                    com.leprino.pm.commands.configData::GetConfigDataCommand/result  

             

                    mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult  

             

                    mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders  

             

                    mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent  

             

                    mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler  

             

                    mx.rpc::Responder/result  

             

                    mx.rpc::AsyncRequest/acknowledge  

             

                    NetConnectionMessageResponder/resultHandler  

             

                    mx.messaging::MessageResponder/result  

             

            Stack trace 2

             

            file:/E:/Akhil/Projects/PlantMaintenance/bin-debug/PlantMaintenance.html   
                Main Thread (Suspended: TypeError: Error #1034: Type Coercion failed: cannot convert mx.collections::ArrayCollection@206a8fc1 to mx.collections.IList.)   
                    com.leprino.pm.commands.dashboard::GetMyWorkRequestsAndOrdersCommand/result   
                    mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult   
                    mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders   
                    mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent   
                    mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler   
                    mx.rpc::Responder/result   
                    mx.rpc::AsyncRequest/acknowledge   
                    NetConnectionMessageResponder/resultHandler   
                    mx.messaging::MessageResponder/result  

             


            Stack trace 3
            When doing dashboardModel.productionSchedule.addAll(data.result as ArrayCollection); and data.result is ArrayCollection but becoming null when casting.

             

            file:/E:/Akhil/Projects/PlantMaintenance/bin-debug/PlantMaintenance.html   
                Main Thread (Suspended: TypeError: Error #1009: Cannot access a property or method of a null object reference.)   
                    mx.collections::ListCollectionView/addAllAt   
                    mx.collections::ListCollectionView/addAll   
                    com.leprino.pm.commands.dashboard::GetProductionScheduleCommand/result   
                    mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult   
                    mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders   
                    mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent   
                    mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler   
                    mx.rpc::Responder/result   
                    mx.rpc::AsyncRequest/acknowledge   
                    NetConnectionMessageResponder/resultHandler   
                    mx.messaging::MessageResponder/result  
            • 3. Re: Problem when using marshall plan
              akhilagrawal Level 1

              Hi,

               

              Some more investivation into the issue. I have tried some of things like removing the marshalling support, not loading the swf file etc.

               

              The type coercion error starts coming only after the swf is loaded. When user login, they land on dashboard, where there are three server calls being made for data and the swf file is also loaded. Whenever data comes after swf, type coercion errors come while if the data comes before that, it doesn't give that error.

               

              All server calls after the swf is loaded gives these type coercion errors.

              • 4. Re: Problem when using marshall plan
                Flex harUI Adobe Employee

                Make sure ArrayCollection is linked into the main app.

                • 5. Re: Problem when using marshall plan
                  akhilagrawal Level 1

                  Hi Alex,

                   

                  Thanks for your help.

                   

                  ArrayCollection is linked in the main application and as it is not giving error for the server calls before the swf is loaded, it means RPC classes were using ArrayCollection class from main application before timeline swf was loaded.

                   

                  It seems like after the timeline swf is loaded in a new application domain, the RPC classes are using the wrong ArrayCollection class for deserialization i.e. ArrayCollection class from the swf application domain instead of using the one from the main application domain.

                   

                  But this shouldn't happen as the two sibling application domains shouldn't use wrong application domain classes, and I think due to some issue with remoting, they are using wrong classes. Basically, I am calling the remoting function from the main application which means it should deserialize the array list java objects into ArrayCollection class in the main application domain but instead it is using ArrayCollection class from timeline swf application domain.

                   

                  I tried the solution of using the bootstrap loader application to load the main application in the child application domain. And now whenever from the main application, the sub application timeline swf is loaded into the new application domain, there is no error with the ArrayCollection as there is only one definition of ArrayCollection which is in the bootstrap loader application domain I believe.

                   

                  Now there are some other errors coming for key handlers and tool tip manager for the main application like the following

                   

                  TypeError: Error #1009: Cannot access a property or method of a null object reference.
                      at mx.managers::FocusManager/defaultButtonKeyHandler()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\managers\FocusManager.as:2028]
                      at flash.events::EventDispatcher/dispatchEventFunction()
                      at flash.events::EventDispatcher/dispatchEvent()
                      at mx.core::UIComponent/dispatchEvent()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\co re\UIComponent.as:12266]
                      at mx.managers::SystemManager/keyDownHandler()[E:\dev\4.0.0\frameworks\projects\framework\sr c\mx\managers\SystemManager.as:2675]

                   

                  ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
                      at flash.display::DisplayObjectContainer/getChildIndex()
                      at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::rawChildren_getChildIndex()[E:\dev\4.0.0\frame works\projects\framework\src\mx\managers\SystemManager.as:2017]
                      at mx.managers::SystemChildrenList/removeChild()[E:\dev\4.0.0\frameworks\projects\framework\ src\mx\managers\SystemChildrenList.as:159]
                      at mx.managers.systemClasses::MarshallingSupport/removeChildFromSandboxRoot()[E:\dev\4.0.0\f rameworks\projects\framework\src\mx\managers\systemClasses\MarshallingSupport.as:1845]
                      at mx.managers.marshalClasses::ToolTipManagerMarshalMixin/removeChildHandler()[E:\dev\4.0.0\ frameworks\projects\framework\src\mx\managers\marshalClasses\ToolTipManagerMarshalMixin.as :159]
                      at flash.events::EventDispatcher/dispatchEventFunction()
                      at flash.events::EventDispatcher/dispatchEvent()
                      at mx.managers::ToolTipManagerImpl/http://www.adobe.com/2006/flex/mx/internal::reset()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\ToolTipManagerImpl.as:1257]
                      at com.leprino.theme.tooltip::NiceToolTipManagerImpl/http://www.adobe.com/2006/flex/mx/internal::systemManager_mouseDownHandler()[E:\Akhil\Proj ects\LeprinoTheme\src\com\leprino\theme\tooltip\NiceToolTipManagerImpl.as:312]

                   

                   

                  ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
                      at flash.display::DisplayObjectContainer/getChildIndex()
                      at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::rawChildren_getChildIndex()[E:\dev\4.0.0\frame works\projects\framework\src\mx\managers\SystemManager.as:2017]
                      at mx.managers::SystemChildrenList/removeChild()[E:\dev\4.0.0\frameworks\projects\framework\ src\mx\managers\SystemChildrenList.as:159]
                      at mx.managers::ToolTipManagerImpl/http://www.adobe.com/2006/flex/mx/internal::reset()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\ToolTipManagerImpl.as:1261]
                      at com.leprino.theme.tooltip::NiceToolTipManagerImpl/http://www.adobe.com/2006/flex/mx/internal::systemManager_mouseDownHandler()[E:\Akhil\Proj ects\LeprinoTheme\src\com\leprino\theme\tooltip\NiceToolTipManagerImpl.as:312]

                   

                   

                  Do you think using bootstrap loader will create more problems like this?

                  • 6. Re: Problem when using marshall plan
                    Flex harUI Adobe Employee

                    I'm not sure you can get away with putting ArrayCollection in a bootstrap.

                    I looks like the issue is that each of your SWFs is registering its own copy

                    of ArrayCollection.  In all players prior to 10.1 (yes, even 10.0) there was

                    only one registerClassAlias table per SecurityDomain regardless of how many

                    applicationDomains there were in the SecurityDomain.

                     

                    This was supposedly fixed in 10.1. Are you testing with 10.1?

                     

                    Other options are to simply call registerClassAlias again after the timeline

                    SWF has loaded, or if timelineSWF doesn't really need arraycollection try to

                    avoid having the timelineSWF register that class.

                     

                    Another option is to put the timeline SWF in another securitydomain so it

                    will get is own registerclassalias table.

                    1 person found this helpful
                    • 7. Re: Problem when using marshall plan
                      akhilagrawal Level 1

                      Thanks for your quick reply. I was testing with flash player 10.0 and now after updating to 10.1, I am not getting those errors. It seems like registerClassAlias table problem has been fixed.

                       

                      I will be going with updating to 10.1 but in case we need to support 10.0 too, I will need to find some solution for that.

                       

                      And even in case of bootstrap or wrapper application, the errors were not coming and also the classes would not be duplicated in both the domains. Right now I am not building multi-versioned apps, so this should be fine but as you say I cannot do that in general for sub app compiled using different version of flex. Is there any other reason why you suggest this may not work?

                       

                      I tried the registerClassAlias for ArrayCollection after the timeline swf is loaded but that doesn't seem to be working. Is this correct -- registerClassAlias("mx.collections.ArrayCollection", ArrayCollection); ? To avoid to not get ArrayCollection registered will not be possible as it might be getting used inside ilog swc.

                       

                      I cannot load the timeline module swf into another security domain as it will be on the same server and may not be able to access through some other url when deployed. (reason being the swf from the same domain cannot be loaded into different security domain - read on some forum).

                      • 8. Re: Problem when using marshall plan
                        Flex harUI Adobe Employee

                        I would think that 10.1 is widely deployed that forcing upgrade from 10.0 to

                        10.1 won't affect 95% of your users.

                         

                        The problem with having ArrayCollection in the bootstrap is simply that it

                        pulls in a lot of other framework classes and will essentially make it

                        impossible to deal with multi-versioned apps.

                         

                        The alias for ArrayCollection is: flex.messaging.io.ArrayCollection

                        Maybe proper re-registration will work.

                         

                        We have recommended to several people that they simply reconfigure DNS to

                        have a single server answer for more than one IP address.  Not sure how well

                        that works for mirrors, edge networks and load-balancing configurations.

                        All Flash cares about is whether the domain portion of the URL string

                        matches.  Thus if you can add an entry for timeline.foo.com, you can host

                        the app at www.foo.com and fetch the timeline swf from the same server at

                        timeline.foo.com and it will go into its own sandbox.  You can even have

                        some way to get the ip address of the server in the main swf and have the

                        main swf load timeline.swf via its ip address.

                         

                        But you are correct that you cannot otherwise create another securitydomain.

                        • 9. Re: Problem when using marshall plan
                          akhilagrawal Level 1

                          Hi Alex,

                           

                          Thanks for your quick replies. The re-registration is still not working. I think updating to 10.1 will solve the issue for us.

                          • 10. Re: Problem when using marshall plan
                            arie6

                            Hi Alex,

                             

                            I have the same problem:

                            - bootstraploader (flex 4.6.0)

                            - main app (flex 4.6.0)

                            - sub app loads in sibling application domain from main (flex 4.1) so i use the marshal plan.

                             

                            So far no problem, both applications (main and sub) have and use their own definition of ArrayCollection.

                             

                            Now the weird thing:

                            if i compile the subapplication with a higher flex version (4.5, 4.5.1 or 4.6.0)

                            it replaces the definition of arrayCollection on the Main app!

                             

                            your suggestion to do a re-register of the ArrayCollection in the main app after the subapp is loaded like

                            registerClassAlias("flex.messaging.io.ArrayCollection", ArrayCollection);

                            seems to do the trick. It doesn't feel like a really solid solution though...

                             

                            Nb i'm using air. Could it be that this is air specific or

                            do you think it might be a regression bug in flash player 11.1?

                             

                            thnx!

                             

                            Arnoud