Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 50

Thread: Flex modules and application context loading

  1. #21
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default works

    Hey Arnoud,

    in my example code this is already how my code looks:

    Code:
    private function loadModules():void {
    				module1.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
    				module2.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
    				
    				module1.loadModule("modules/SASDemoModule1.swf");
    				module2.loadModule("modules/SASDemoModule2.swf");
    }
    and it works fine.

    I am still convinced that this is an IDE problem. I will have to test more but all I know is that the difference between my project and yours is that mine was created from scratch and yours has imported the source directories from an SVN checkout. After that you manually added the modules to your project, etc. Maybe this is a flexbuilder/flashbuilder bug where in this scenario the wrong compiler settings are being generated.

    This error sort of gives it away:
    Code:
    ReferenceError: Error #1065: Variable ISASModule is not defined
    This is theoratically impossible, the loaded module IMPLEMENTS THIS INTERFACE.
    Therefore this smells to me like a configuration that is screwed up somewhere, its definitely NOT an SAS issue.
    When I find the time I'll try and sift throught the generated project config files for the two different flex projects to see if I can find some kind of differences between them. I'm not sure when though because I'm rather busy at work at the moment, but I promise I'll look into it a.s.a.p.


    cheers,

    Roland

  2. #22

    Default we just don't agree :D

    Hi Roland,

    The funny thing is that i'm still convinced that it's a SAS problem.

    in your previous remark you say:

    "This error sort of gives it away:"

    Code:
    ReferenceError: Error #1065: Variable ISASModule is not defined
    "This is theoratically impossible, the loaded module IMPLEMENTS THIS INTERFACE."

    But under the reference error it gives more details on the error:
    Code:
    at global/flash.utils::getDefinitionByName()
    	at org.as3commons.lang::ClassUtils$/getImplementedInterfaces()[/home/christophe/IdeaProjects/as3commons/as3-commons-lang/src/main/actionscript/org/as3commons/lang/ClassUtils.as:282]
    	at org.as3commons.reflect::Type$/forClass()[/home/christophe/IdeaProjects/as3commons/as3-commons-reflect/src/main/actionscript/org/as3commons/reflect/Type.as:156]
    	at org.springextensions.actionscript.ioc.autowire:
    I'm not convinced at all the reflect package is looking in the right applicationDomain to find the definition... For example it may well lookup the ISASModule in the application domain which indeed doesn't have it.

    The project doesn't work in both flash builder 4 beta2 and flex builder 3 so it's not an IDE issue, i think. But i'll make an ant build and post the project to make sure it's not my system that's acting weird. i'll post more if i know more!

    cheers,

    Arnoud

  3. #23
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default still i disagree

    Hey Arnoud,

    the problem that remains with this is that my original project WORKS PERFECTLY.
    Its a flexbuilder 3 project, and I have absolutely NO PROBLEMS. If I create a new project in flashbuilder and set the source folder to the original project I get the errors, so I still think this is some sort of configuration issue somewhere.

    I'm very interested to hear what your ANT build will turn out like, because I'm completely stumped about the entire problem...

  4. #24
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default hmmm

    Even weirder. If I open both projects, so my original flexbuilder 3 project and the flashbuilder project. (So both projects point to the same source directory).

    When I compile and run with Flexbuilder 3, no errors, works perfectly.

    When I compile and run with Flashbuilder, *BOOM*, the exceptions are flying...

    Tell me that is not an IDE/config issue...

  5. #25
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default The plot thickens

    I still haven't got the faintest clue why my original project works and the imported projects don't. Yet in my spelunking through the source code I MIGHT have stumbled upon a bug in as3commons-reflect.
    But let me stress, I'm not sure yet, I need to investigate further...

  6. #26

    Default conclusive....

    Hi Roland, i'm hoping im not driving you crazy with my wining about the modules contexts with custom classes

    Ok I think i can prove there is a bug in the reflection handling.

    First of all, the reason that your original project works is that you do not define and retreive a custom class fom a module context. That's why i send you the modified version.

    That you original project doesnt work in flash builder 4 is weird, but including the next line fixes that:

    Code:
    import org.springextensions.actionscript.module.ISASModule; ISASModule;
    that is really the only IDE problem, but the rest is working fine.

    Now i created build files for my project and guess..... same problem
    the project is too big to attach here so i placed it online:

    http://www.artim-interactive.nl/arno...module_sas.zip

    follow the next steps:

    import it in flex builder 3 and build it with the ide.
    you will get a run time....

    now uncomment the next lines in application.mxml
    Code:
    /* import org.springextensions.actionscript.module.ISASModule; ISASModule;
    import classes.ModuleClassImpl; ModuleClassImpl; */
    build / run again from the IDE and you will see that the app works. The conclusion that can be drawn from this is that the module doesn't look up custom classes in it's own application
    domain
    but directly looks in the root application domain. This MUST be the problem

    Now to prove this has nothing to do with the ide: Lets do ant now:

    put the next to lines in application.mxml in comments again
    Code:
    /* import org.springextensions.actionscript.module.ISASModule; ISASModule;
    import classes.ModuleClassImpl; ModuleClassImpl; */
    open your shell, go to the project root.
    run ant -f flex2ant-build.xml

    after done open application.html in bin-debug. the module information doesn't show, right?

    uncomment the next to lines (i know it gets repetitive )

    Code:
    /* import org.springextensions.actionscript.module.ISASModule; ISASModule;
    import classes.ModuleClassImpl; ModuleClassImpl; */
    open your shell, go to the project root.
    run ant -f flex2ant-build.xml

    after done open application.html.

    and now it works, the same behavior as flash builder and flex builder.

    to me it's definitely a reflection / application domain problem.

    Application domains are really a more complex thing than a first sight and with modules thing get even more unclear. I recently have done some investigation for the project i'm working on and i really am the more convinced the problem lies in this area.

    hope this gives a good start point for investigating the problem further.

    cheers,

    Arnoud

    NB if you have problems running the ant target uncomment the next line in your flex-config.xml:

    Code:
     <local-fonts-snapshot>localFonts.ser</local-fonts-snapshot>
    Last edited by arnoudb; Oct 28th, 2009 at 05:04 PM. Reason: make text clearer

  7. #27
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default still not an SAS problem.

    Please refer to my previous three posts, it seems like you missed those.
    First of all, again, this statement:
    you do not define and retrieve a custom class from a module context
    is not true.
    In module1-context.xml this is defined:
    Code:
    <object id="customClass" class="classes.ModuleClass"/>
    This means this object is a singleton, so it will be instantiated by the application context residing in the module's applicationDomain immediately in its startup cycle, if there was an applicationdomain problem then the context would already crash BEFORE any stage wiring takes place.

    Now, like I stated in my previous post, I did find an indication that there might be a problem in as3common-reflect, but I'm not sure yet, I'm investigating.
    And STILL, like I also stated in my previous post, I have this bizarre situation where I compile the SAME source code first in flexbuilder 3, than in Flashbuilder and the former WORKS, yet the latter CRASHES.

    So, while I agree that this is probably a reflection bug, it remains a complete mystery to me why my original project works flawlessly.

    I'll keep you posted on my findings in as3-commons.

    Application domains really aren't that difficult to be honest, the documentation surrounding them just kind of sucks. Right now I'm confident that SAS keeps track of its application domains properly, yet now looms the question whether as3-commons is screwing up somewhere.

    Anyways, the quest continues, and I still appreciate your comments and research, honestly Its a gnarly problem, but one that needs to be solved a.s.a.p.

    cheers,

    Roland

  8. #28
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default for completist sake

    Hey Arnoud,

    PM me your email adres, I will send you the compiled version of my project, than you can see it works. It still doesn't solve our problem, but at least you'll know for sure that I'm really not bullshitting you

    cheers,

    Roland

  9. #29

    Default haha :D

    Hi Roland,

    i did read your posts very well but apparently i'm not clear with my description?

    what i mean with define and retreive an object from the context is something like: first define it in the context. Ok you do that, great!
    and then retreive it by for example autowiring a model variable on stage with it. The last part you don't do in your project, right?

    So the class is defined in the context, it exists there, is happy over there making friends with other singletons etc... , but the problems arise when retreiving a reference to that object. There's the problem. Cause obtaining a reference to the object goes trough reflection, and it works if the custom class is included in the parent application. Otherwise not. My logic says then that the reflection call looking up the class is looking in the wrong applicationDomain. that of the parent application instead of the one of the module.

    Obviously everything works fine if the module is loaded in ApplicationDomain.currentDomain; In that case the reference to the custom class doesn't have to be in main but can be in Module only. This because it's added to the main applicationDomain when the module loads. Reflection in effect can only look in ApplicationDomain.curentDomain in that case because besides systemDomain it's the only domain around. Your test application works is because you only RETREIVE string values which are defined in the systemDomain which is a special case....

    So my conclusion is that this behavior shows that custom classes are always looked up in the root application domain, which is obviously wrong cause they may live in the module applicationDomain. So first the applicationDomain of the module should be checked, if no definition is found there go to the next level etc...

    Now i really wonder if there's a hole in this logic because i try (not very successfully ) to point this out in my previous posts...
    Did you try the steps that i described?

    That flash builder 4 requires the import of ISASmodule is unclear to me, but i already explained that that is the only bug youhave to work arounfd to get is working (well compiling....), and that for the rest it works the same way in flex builder 3 or a build with ant.

    But i'll look at your project for sure! But a compiled version doesn't say much right, so included source would be nice....
    you can mail the project to arnoud at artim-interactive dot nl

    But c'm on you are not convinced after my previous post ?

    cheers, (even if this takes 30 more posts we gonna nail this sucker, right? )

    Arnoud
    Last edited by arnoudb; Oct 28th, 2009 at 07:29 PM.

  10. #30
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default nope, we're still in a state of flux

    Ok, here we go again

    the compiled application's source code I was going to send you, you already have the source code for. Its the exact source that is in SVN, I just compile that source with either FB3 or Flashbuilder.
    My conclusion now is that somehow reflection behaves differently between those two compiles, and I have no clue why. I did however find that in some cases in the as3-common-reflect library no application domain is passed to methods that might actually need it.

    Where the ISASModule error is thrown is the moment where SASDemoModule1 gets wired. In the code where the definition (by calling Type.forClass()) of SASDemoModule1 is retrieved everything works fine until the implemented interfaces are enumerated, at the moment that the ISASModule definition is requested things break.

    And here's where I don't get it anymore, the SASDemoModule1 type is the class of the loaded module, this module resides in its own application domain, and now the definition for SASDemoModule1 is returned without trouble, yet ISASModule throws an error.
    And again, it only does this when I compile the exact same code in flashbuilder, FB3 gives no errors.

    I'm now experimenting with adding an optional application domain to the static Type methods, this will hopefully solve the problem, yet it will still not answer my question WHY this works in one IDE and not in the other.

    I'm stumped, stupefied and utterly confused.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •