Announcement Announcement Module
Collapse
No announcement yet.
Flex modules and application context loading Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Flashbuilder is the problem

    Ok, I've tried getting the example app to work in Flashbuilder and get exactly the same errors as the ones you reported.
    I think this pretty much confirms my suspicions, its an IDE problem.
    I'll try and see if I can find time to figure out where things screw up, but again, Flashbuilder is still a beta product so I'm not going to spend too much time on this since the product is still subject to change.
    Until then I guess you're more or less stuck with flexbuilder 3, I'm sorry.
    Should you be able to find out yourself what exactly goes wrong in Flashbuilder then I'd really like to hear about it.

    cheers,

    Roland

    Comment


    • #17
      I'll give it another go....

      Hi Roland,

      If i sounded sarcastic i am sorry about that, but it was not my intention at all. I'm really happy that you guys are so responsive! Just thought getting that out of the way first.

      First of all I am using flex 3.4.

      I am really curious if you can make the example work. The need for adding ISASModule is indeed strange but not because of the reason you say i think. Cause in my opinion SASModule is not used in Main so it's obvious that ISASModule is not linked in. What is strange imho is that Main needs ISASModule anyway.

      But the point still open is: Can you proof that you can actually reference / autowire a custom class that is defined in a module context and that is not available in the application context. I have a hard time believing that you can get my example to wok in flex builder 3. Because without sarcasm , i still believe the multi module example doesn't proof that.

      cheers,

      Arnoud

      Comment


      • #18
        flex builder 3 same problems, no ide issue ...

        Hi Roland,

        As i suspected i have the same problem in flex builder 3 (with sdk 3.3).

        So main needs to include ISASModule (and i'm just using the source of SAS, no swc, so no missing classes due to unchecked checkboxes). otherwise this error:

        Code:
        Sun Oct 25 14:56:19 GMT+0100 2009 DEBUG - org.springextensions.actionscript.ioc.wire.DefaultObjectDefinitionResolver - Can't find a prototype scoped IObjectDefinition whose type match the object type for _poc_multi_module_sas0.module2.SASDemoModule2_13
        Sun Oct 25 14:56:19 GMT+0100 2009 DEBUG - org.springextensions.actionscript.ioc.wire.DefaultObjectDefinitionResolver - Using default IObjectDefinition for _poc_multi_module_sas0.module2.SASDemoModule2_13
        ReferenceError: Error #1065: Variable ISASModule is not defined.
        	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/

        and if i include it i get the next familiar one. even though module 1 has the
        definition of the class: inside module 1 (and they are not referenced in main):

        Code:
        import classes.ModuleClass;
        import classes.ModuleClassImpl;
        private var forceInCludeClasses:Array = [ModuleClassImpl];
        the error:

        Code:
        Sun Oct 25 15:00:57 GMT+0100 2009 DEBUG - org.springextensions.actionscript.context.support.XMLApplicationContext - No external properties file reference found.
        Sun Oct 25 15:00:57 GMT+0100 2009 INFO - org.springextensions.actionscript.ioc.factory.support.DefaultListableObjectFactory - Pre-instantiating singletons in [object FlexXMLApplicationContext]
        Sun Oct 25 15:00:57 GMT+0100 2009 WARN - org.as3commons.reflect.Type - Type.forName error: Error #1065: Variable ModuleClassImpl is not defined. The class 'classes.ModuleClassImpl' is probably an internal class or it may not have been compiled.
        ReferenceError: Error #1065: Variable ModuleClass is not defined.
        	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::DefaultAutowireProcessor/getUnclaimedSimpleObjectProperties()[/Users/arnoudbos/Desktop/development/flex frameworks svn/spring-actionscript/trunk/spring-actionscript-core/src/main/actionscript/org/springextensions/actionscript/ioc/autowire/DefaultAutowireProcessor.as:412]
        	at org.springextensions.actionscript.ioc.autowire::DefaultAutowireProcessor/autoWire()[/Users/arnoudbos/Desktop/development/flex frameworks svn/spring-actionscript/trunk/spring-actionscript-core/src/main/actionscript/org/springextensions/actionscript/ioc/autowire/DefaultAutowireProcessor.as:157]
        	at org.springextensions.actionscript.ioc.factory.support::AbstractObjectFactory/wire()[/Users/arnoudbos/Desktop/development/flex frameworks svn/spring-actionscript/trunk/spring-actionscript-core/src/main/actionscript/org/springextensions/actionscript/ioc/factory/support/AbstractObjectFactory.as:321]
        	at org.springextensions.actionscript.ioc.factory.support::AbstractObjectFactory/getObject()[/Users/arnoudbos/Desktop/development/flex frameworks svn/spring-actionscript/trunk/spring-actionscript-core/src/main/actionscript/org/springextensions/actionscript/ioc/factory/support/AbstractObjectFactory.as:289]

        that error disappears if i load the module in the same application domain as main instead of a child domain or if i include

        Code:
        <object id="customClass" class="classes.ModuleClassImpl"/>
        in main application context.

        and
        Code:
        import classes.ModuleClassImpl; ModuleClassImpl;
        in main.

        This all still leads to my conclusion that
        custom classes in a module context break if modules are loaded in child application domains.

        When looking up classes in the modulecontext to for example autowire a view property, the module context is skipped and only the main context is inspected. Hope this helps out.

        cheers,

        Arnoud
        Last edited by arnoudb; Oct 25th, 2009, 09:28 AM. Reason: typo

        Comment


        • #19
          its a flashbuilder issue

          Hey Arnoud,

          as I've stated in my previous post, its not an SDK issue, its an IDE issue. I've tried getting the example application to work in Flashbuilder with SDK 4.0 and with SDK 3.4, both give the errors that you posted.

          Yet, when I build my application with FlexBuilder 3 it works. That's why I mentioned the fact that flashbuilder is a beta product, I don't know WHY its screwing up, bit its definitely the fault of Flashbuilder.
          Have you tried building the example in Flexbuilder 3? I mean the IDE, not the SDK. Sorry for the confusion.

          cheers,

          Roland

          Comment


          • #20
            haha

            Yeah, we have some confusion. :-)

            but as statet in the message title and in the first line of my previous message i did try the example in flex builder 3 with sdk 3.3

            so here the same problems in flash builder and flex builder, don't know what's up. That was why my conclusion was that it's the framework....

            strange shit. I'll test some more.

            in the mean time to be absolutely sure we talk about the same stuff here.
            dit you try my example in flex builder 3 or your example?

            if you used mine try changing something in main:
            So change the applicationdomain for module1. Change:

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

            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");
            			}
            if that works for you i'll eat my shoe :-D

            Arnoud

            Comment


            • #21
              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

              Comment


              • #22
                we just don't agree

                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

                Comment


                • #23
                  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...

                  Comment


                  • #24
                    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...

                    Comment


                    • #25
                      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...

                      Comment


                      • #26
                        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, 05:04 PM. Reason: make text clearer

                        Comment


                        • #27
                          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

                          Comment


                          • #28
                            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

                            Comment


                            • #29
                              haha

                              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, 07:29 PM.

                              Comment


                              • #30
                                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.

                                Comment

                                Working...
                                X