4 Replies Latest reply on Apr 11, 2010 9:34 PM by saisri2k2

    Getting the following Exception after the module is loaded into the client

    saisri2k2 Level 4

      I'm getting the following error after the module is loaded into the memory what culd be the reason?

       

      I've loaded the module using ModuleLoader and after the module ready event i get the following exception.

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
           at mx.core::UIComponent/get parentApplication()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:2781]
           at mx.core::Container/createChildren()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2579]
           at mx.core::UIComponent/initialize()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:5370]
           at mx.core::Container/initialize()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2526]
           at com.zts.hygeia.ui.modules.visit::VisitModule/initialize()[C:\Hygeia\Dev\workspace-nw-parallel\HygeiaUIModules\src\com\zts\hygeia\ui\modules\visit\VisitModule.mxml:0]
           at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:5267]
           at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:3305]
           at mx.core::Container/addChildAt()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2217]
           at mx.core::Container/addChild()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2140]
           at mx.modules::ModuleLoader/moduleReadyHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\modules\ModuleLoader.as:360]
           at flash.events::EventDispatcher/dispatchEventFunction()
           at flash.events::EventDispatcher/dispatchEvent()
           at ModuleInfoProxy/moduleEventHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\modules\ModuleManager.as:1097]
           at flash.events::EventDispatcher/dispatchEventFunction()
           at flash.events::EventDispatcher/dispatchEvent()
           at ModuleInfo/readyHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\modules\ModuleManager.as:752]
           at flash.events::EventDispatcher/dispatchEventFunction()
           at flash.events::EventDispatcher/dispatchEvent()
           at mx.core::FlexModuleFactory/update()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:327]
           at mx.core::FlexModuleFactory/docFrameHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:418]
      
       
      
        • 1. Re: Getting the following Exception after the module is loaded into the client
          saisri2k2 Level 4

          I'm doing the following to load the module

           

           

          _modLoader =  new ModuleLoader();
                         m_hmModule.put(mod,_modLoader);
                         _currModule = mod;
                         
                         switch(mod){
                              case IHygeiaConstants.MOD_VISIT:
                                   //url += ApplicationDomain.currentDomain.toString()+"/";
                                   url += HygeiaConfig.getInstance().getModuleUrl(IHygeiaConstants.MOD_VISIT)+"?";
                                   
                                   
                                   for each(var keys:String in params.getKeys()){
                                        url += keys + "=" + params.getValue(keys)+"&";
                                   }
                                   url = url.substr(0,url.length-1);
                                   break;                    
                         }
                         
                         if(_modLoader){
                              _modLoader.addEventListener(ModuleEvent.READY,readyMod);
                              _modLoader.addEventListener(ModuleEvent.ERROR,loadError);
                              _modLoader.addEventListener(ModuleEvent.PROGRESS,loadProgress);
                              _modLoader.addEventListener(ModuleEvent.UNLOAD,unload);
                              _modLoader.applicationDomain = ApplicationDomain.currentDomain;
                              
                              _modLoader.addEventListener(FlexEvent.PREINITIALIZE,mLoaderPreinit);
                              _modLoader.url = url;
                              _modLoader.loadModule();
                         } 
                    }
                    
                    private function mLoaderPreinit(evt:FlexEvent):void{
                         _modLoader.moduleFactory = Application.application.systemManager;
                    }
                    
                    private var oMod:IHygeiaModule;
                    public function readyMod(evt:ModuleEvent):void{
                         /* var oMod:IHygeiaModule = evt.module.factory.create() as IHygeiaModule;
                         oMod.initModule(Application.application as IHygeiaApp);  */
                         oMod = _modLoader.child as IHygeiaModule;
                         
                         _modLoadFunc(_currModule,oMod);
                    }
          

           

           

           

          AFter the  following part i get exception that is given above.. Some how the module could not get handle to the SystemManager. That is why it is throwing the error.

           

           

          public function readyMod(evt:ModuleEvent):void{
                         /* var oMod:IHygeiaModule = evt.module.factory.create() as IHygeiaModule;
                         oMod.initModule(Application.application as IHygeiaApp);  */
                         oMod = _modLoader.child as IHygeiaModule;
                         
                         _modLoadFunc(_currModule,oMod);
                    }
          

           

           

          ----------------

          More info :

           

          When i debug the app i get the exception at the following point of the mx.core.Container.as

           

           

             public function get parentApplication():Object
              {
                  // Look for the SystemManager's document,
                  // which should be the Application.
                  var o:Object = systemManager.document;      // <<< here i get null pointer on the systemManager
                  
                  // If this UIComponent is its own root, then it is an Application.
                  // We want to return its parent Application, or null
                  // (if it has no parent because it is the top-level Application).
                  // The hierarchy in this situation looks something like this:
                  //
                  //  SystemManager
                  //      Application
                  //          SomeContainer
                  //              Loader
                  //                  Loaded App's SystemManager
                  //                      Application
                  //                          ThisComponent
                  if (o == this)
                  {
                      var p:UIComponent = o.systemManager.parent as UIComponent;
                      o = p ? p.systemManager.document : null;
                  }
          
                  return o;
              }
          
           
          

           

          Message was edited by: saisri2k2

          • 2. Re: Getting the following Exception after the module is loaded into the client
            Flex harUI Adobe Employee

            Maybe the ModuleLoader doesn't have a parent?

            • 3. Re: Getting the following Exception after the module is loaded into the client
              saisri2k2 Level 4

              How do I set the parent to this module? I'm following regular way of 

              loadingg the module. Shud I set somthing here?

               

              Regards

              Sai

              • 4. Re: Getting the following Exception after the module is loaded into the client
                saisri2k2 Level 4

                I had to override initialize() method of the module to stop the exception. every thing else is working fine now. Hope nothing breaks by doing tis.