5 Replies Latest reply on Jul 13, 2011 2:52 AM by Carlos_Rovira

    RemoteClass alias being lost

    MackrorySD

      I have a custom component being used in several modules (some of them are extremely similar modules) that is mapped to a Java class on the backend. I have a lot of other components doing the same thing, and they've all been working beautifully, but I've noticed that in some modules, 2 of the components can't be mapped to the backend. Instead, they get passed as "ASObjects", and the call fails, returning a fault.

       

      I have the metadata tag [RemoteClass(alias="")] and I'm 100% confident the class path is correct. The exact same component is working fine in some modules, but not in others. In the modules where it doesn't work, there are other, similar components failing in the same way. I called "describeType" on the components, and I've noticed that when the call work, the type tag contains the alias information, and when it fails, the alias information was missing. Can anyone think of any factor that would be causing the alias to no longer be registered with that class?

        • 1. Re: RemoteClass alias being lost
          Flex harUI Adobe Employee

          RemoteObject classes should be in the main app.  They just don't work well in modules.  You can use a shared-code module to install those classes after startup if you want, but anything shared between modules must be in the main app or shared-code module.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: RemoteClass alias being lost
            MackrorySD Level 1

            I tried compiling the offending controls into a runtime-shared-library and sharing that, and it worked! However that gave rise to all sorts of other problems, including a significant decrease in runtime (I've tried many different configurations before - there's just enough variation between each of my modules that I really can't find a way to get a speed benefit from RSL), and state issues with buttons (a button will have it's enabled property set to true, but show itself as disabled until I mouse over it - upon mousing over - it changes to it's enabled state for no apparent reason), and all sorts of seemingly unexplainable anomalies in the EDA (I have a function B that is only ever called by function A, but function B executed before function A... ??)

             

            I read your presentation about modules and application domains, and my guess is that the problem I'm having with RSL's are similar in nature - that it's a matter of scope, etc... The program is performing perfectly well without the RSLs, with this one exception of the components that need to have the backend do some of the work. What really confuses me is that they work in some modules and not in others, and the modules are almost identical.

             

            I realize my program obviously doesn't sound like the best design - but it's web client for a legacy application, so I myself don't have a lot of control over some of the design - but I'm still hoping there's a more technical explanation behind what's happening then RO's just "not working well" in modules - I think it would be much better to adjust my module/component to avoid the problem than use RSL's and deal with a whole new set of bugs. The problem is I can't seem to find any technical difference between the two uses of my component, and none of the documentation I've seen online deals with that...

             

            But thanks for the help - the fact the RSL's fixed that particular bug is a major clue, even if it caused other unexplained problems...

            • 3. Re: RemoteClass alias being lost
              Flex harUI Adobe Employee

              The remoteclass issue is similar to the other modules issues in my presentation.  There is only one class alias table in each sandbox.  If moduleA brings in MyDataClass and registers it with the alias table, it has registered MyDataClass@moduleA, and when module brings in its MyDataClass and registers it, it replaces the alias with MyDataClass@moduleB and when moduleA's result returns, the player converts it to MyDataClass@moduleB and the types don't match.

               

              Hopefully, the only thing in your RSL or main app or sharedcode module is the data class and maybe a few other classes that get shared.  That might eliminate the behavior differences you're seeing.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              • 4. Re: RemoteClass alias being lost
                bryn51

                You might want to try using registerClassAlias  ( e.g. flash.net.registerClassAlias)

                 

                 

                 

                 

                 

                to expressly set the alias value (a string) just before instantiating the remote class.

                 

                The way I am using it, I dont set the value of alias in the .as package that defines the remote class

                I use [ RemoteClass ] in the calling routine.

                 

                instead of [RemoteClass(alias="....")]

                 

                This has the pleasant side effect of making it possible to set the path to the remote class in an external config file

                and feeding it in via FlashVars, thus making the application more portable without having to adjust the flex code when it gets deployed from dev into production.

                 

                 

                Cheers,

                Bryn

                 

                 

                 

                 

                instead of [RemoteClass(alias="....")]

                 

                This has the pleasant side effect of making it possible to set the path to the remote class in an external config file

                and feeding it in via FlashVars, thus making the application more portable without having to adjust the flex code when it gets deployed from dev into production.

                 

                 

                Cheers,

                Bryn

                 

                 

                 

                 

                 

                 

                • 5. Re: RemoteClass alias being lost
                  Carlos_Rovira

                  Hi,

                   

                  my app is multimodule. I'm creating flex libraries with DTOs (all classes has a RemoteClass in top of the code).

                  I'm loading all DTO libs as RSLs in "top-level" and force-load true.

                   

                  I'm getting messages like this:

                   

                   

                  warning: The class XXX has been used in a call to net.registerClassAlias() in _mymodule_FlexInit. This will cause mymodule to be leaked. To resolve the leak, define XXX in the top-level application.  

                   

                   

                  I get a workaround if I define a var in main app that force a compilation of the DTO class

                   

                  ej: private var a:Array = [XXX,....]

                   

                  but this is very, very, very inconvenient since it must to be manually updated and could cause errors.

                   

                  So it there some other way to solve this problem?

                   

                  Thanks in advance

                   

                  Carlos Rovira