Announcement Announcement Module
Collapse
No announcement yet.
I must be overlooking something very simple! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • I must be overlooking something very simple!

    Hello group, I just started trying to integrate with spring-actionscript today and have run into a small problem. In reading the getting started section of the help file it all looks so simple and straight-forward, but alas I have not been successful at getting a demo up and running.

    I am using FlexBuilder 3, Flex SDK 3.3, Flash Player 10 (Debug), and spring-actionscript-0.7.1.

    Everything compiles fine but when I deploy and run the Flex application I get this error:

    Error: An object definition for 'exampleUser' was not found.
    at org.springextensions.actionscript.ioc.factory.supp ort::AbstractObjectFactory/getObject()[C:\Users\Christophe\Documents\Adobe Gumbo MAX Preview\spring-actionscript\core\src\main\actionscript\org\spring extensions\actionscript\ioc\factory\support\Abstra ctObjectFactory.as:138]
    at SpringActionScriptExample/applicationContext_completeHandler()[D:\repo\trunk\source\SpringActionScriptExample\src \SpringActionScriptExample.mxml:46]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_doParse()[C:\Users\Christophe\Documents\Adobe Gumbo MAX Preview\spring-actionscript\core\src\main\actionscript\org\spring extensions\actionscript\ioc\factory\xml\XMLObjectF actory.as:343]
    at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_loadNextProperties()[C:\Users\Christophe\Documents\Adobe Gumbo MAX Preview\spring-actionscript\core\src\main\actionscript\org\spring extensions\actionscript\ioc\factory\xml\XMLObjectF actory.as:315]
    at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_loadNextConfigLocation()[C:\Users\Christophe\Documents\Adobe Gumbo MAX Preview\spring-actionscript\core\src\main\actionscript\org\spring extensions\actionscript\ioc\factory\xml\XMLObjectF actory.as:291]
    at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_onLoaderComplete()[C:\Users\Christophe\Documents\Adobe Gumbo MAX Preview\spring-actionscript\core\src\main\actionscript\org\spring extensions\actionscript\ioc\factory\xml\XMLObjectF actory.as:241]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()
    I tested hitting the URL of the applicationContext.xml file and verified that is it present and accessible.

    Here is the content of my applicationContext.xml file:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <objects xmlns="http://www.springactionscript.org/schema/objects"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.springactionscript.org/schema/objects
                                  http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd">
    
        <object id="exampleUser" class="examples.UserProfile">
          <property name="firstName" value="John" />
          <property name="lastName" value="Doe"/>
          <property name="age" value="41"/>
        </object>	
    </objects>
    And here is my application MXML file:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    	            layout="absolute"
    	            creationComplete="initApplication();">
    
        <mx:Script>     
        <![CDATA[
        	import examples.UserProfile;
        	import mx.controls.Alert;
        	import org.springextensions.actionscript.context.support.FlexXMLApplicationContext;
        	import as3reflect.ClassUtils;
        
            // Spring ActionScript IOC
            private var applicationContext:FlexXMLApplicationContext;
    
       
            /**
            * application complete event handler 
            */
            public function initApplication():void
            {
                // create new application context
                applicationContext = new FlexXMLApplicationContext();
                
                // define application context configuration file
                applicationContext.addConfigLocation("applicationContext.xml");
    
                // register load complete listener and then load the application context XML file
                applicationContext.addEventListener(Event.COMPLETE,applicationContext_completeHandler);
                applicationContext.addEventListener(IOErrorEvent.IO_ERROR,applicationContext_IOErrorHandler);
                applicationContext.load();
            }
    	
    	
            /**
            * 
            * application context (spring IOC container) 
            * event handler for load complete 
            * 
            */
            private function applicationContext_completeHandler(event:Event):void
            {
                Alert.show("[IOC] Object definitions loaded: " + applicationContext.numObjectDefinitions.toString());
    
                // instantiate example user object
                var exampleUser:UserProfile   = applicationContext.getObject("exampleUser") as UserProfile;
                Alert.show("[IOC] User Profile=" + exampleUser.firstName + " " + exampleUser.lastName); 
            }
            
            
            /**
            * 
            * application context (spring IOC container) 
            * event handler for IO error
            *  
            */
            private function applicationContext_IOErrorHandler(event:IOErrorEvent):void
            {
            	Alert.show("[IOC] IO Error : " + event.text); 
            }
    
        ]]>
        </mx:Script>	
    </mx:Application>
    And finally, my UserProfile class file:

    Code:
    package examples
    {
    	public class UserProfile
    	{
    	    private var _firstName:String;
    	    private var _lastName:String;
    	    private var _age:int;
    	    
    	    public function UserProfile():void
    	    {
    	       // constructor
    	    }
    
    	    public function set firstName(value:String):void 
    	    {
                _firstName = value;
    	    }
            public function get firstName():String
            {
                return _firstName;
            }
    
    	    public function set lastName(value:String):void 
    	    {
                _lastName = value;
    	    }
            public function get lastName():String
            {
                return _lastName;
            }
    
    	    public function set age(value:int):void
    	    {
                 _age = value;
    	    }
            public function get age():int
            {
                 return _age;
            }   
    	} 
    }
    So no matter what I try, I cannot get the spring-actionscript container to instantiate the UserProfile object instance at runtime. The 'applicationContext.numObjectDefinitions' always returns a value of '0'. It make me think the XML is not formed correctly? But I based this example code directly from Chapter 2 @ http://www.springactionscript.org/do...on.html#d4e218

    I'm sure this is just some simple oversight, but any help would be greatly apprciated. I'm looking forward to delving further into the IOC and DI implementation but have to get past this first hurdle :-)

    I have attached my source project, but to meet the ZIP file size limitations imposted by the forum, I had to remove the following two dependency libraries from the "libs" folder:
    • as3reflect.swc
    • spring-actionscript.swc

    Thank You!

  • #2
    Namespace and schema locations

    I think it might just be the the namespace and schema locations - I replaced the first line of your appcontext file with:

    <objects xmlns="http://www.pranaframework.org/objects"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.pranaframework.org/objects
    http://www.pranaframework.org/schema/objects/prana-objects-0.6.xsd">

    and it worked for me . This is a one area I have been a bit confused by. So maybe it's a good follow up question for someone else - If I am using 0.7.1 and will be using .8 when it's officially released, what namespace and schema location should I be used with that version? I am using the one above and it works but it seems weird to still be referencing prana and 0.6.

    Comment


    • #3
      no entry

      hi,

      your code is working fine. dont add anything in ur applicationContext.xml.
      he is doing the same
      http://coenraets.org/blog/2009/03/th...-1-the-basics/

      Comment


      • #4
        Originally posted by jrayhawk View Post
        I think it might just be the the namespace and schema locations - I replaced the first line of your appcontext file with:

        <objects xmlns="http://www.pranaframework.org/objects"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.pranaframework.org/objects
        http://www.pranaframework.org/schema/objects/prana-objects-0.6.xsd">

        and it worked for me . This is a one area I have been a bit confused by. So maybe it's a good follow up question for someone else - If I am using 0.7.1 and will be using .8 when it's officially released, what namespace and schema location should I be used with that version? I am using the one above and it works but it seems weird to still be referencing prana and 0.6.
        Hi jrayhawk,

        Thanks for the tip! I did change the <objects> namespace to what you mentioned and it is working great now! I also tested it without any namespace defined and that worked fine too.

        So I guess the documented example here is just a little ahead of it's time for the current release version: http://www.springactionscript.org/do...on.html#d4e218

        Thanks again!

        Comment


        • #5
          Originally posted by Falko View Post
          hi,

          your code is working fine. dont add anything in ur applicationContext.xml.
          he is doing the same
          http://coenraets.org/blog/2009/03/th...-1-the-basics/

          Hi Falco,

          When I made the suggested change to using the older namespace and schema def it started working like I expected. I also looked at the link you provided and noticed that the example there did not have any namespace defined for the <objects> node, so I tried that and removed the namespace and schema location and it worked fine that way too.

          Thanks!

          Comment


          • #6
            XSD Validation?

            Leaving it out works but it seems like it would be good to include it to allow your schema-aware tools to perform validation to make sure you building it according to spec based on the version of Spring ActionScript you are going to use. This link seems to indicate this as well: http://www.springactionscript.org/do...reference.html. I also noticed this comment in the XMLApplicationContext.as file:

            * <strong>Important: </strong> the schemeLocation within the application context xml file (in the example
            * <code>http://www.pranaframework.org/schema/objects/prana-objects-0.6.xsd</code>)
            * should contain the version of prana you are using.

            Does anyone know why including it exactly as mentioned in this link seems to cause problems?

            Comment


            • #7
              Hi jrayhawk,

              I did add the namespace and schema defined as you provided in the example above. All is working great now! I did leave them defined for XSD validation in my sources.

              Thank You for you help!
              Last edited by rrsavage; Jun 26th, 2009, 04:52 PM.

              Comment


              • #8
                yes, its a namespace issue

                Hey there guys,

                yes, this is indeed a namespace issue. Since the code was taken from the www.springactionscript.org documentation, which I'm writing in sync with the upcoming version 0.8 release, but the 0.7.1 release was used, things were clashing.

                In version 0.8 the schema location that point to the pranaframework.org urls will have been deprecated and a complete move to the springactionscript.org will have been performed. Users moving from 0.7.1 or lower will have to change these namespaces when they start using version 0.8. This will be a one-time action.

                I apologize for this, please understand this is a one time confusion, after version 0.8 we will have been ported 100% to Springactionscript and will the name Prana be gone completely. Until then, please bear with us.

                I'm happy to see that at least other users were able to pinpoint the culprit, thanks guys!

                cheers,

                Roland
                Last edited by 666shooter; Jun 26th, 2009, 01:38 AM. Reason: added some extra comments about the namespace change

                Comment


                • #9
                  Is there an eta for the 0.8 release out of curiosity?

                  Comment


                  • #10
                    eta unknown...

                    Hey Milkdud,

                    the ETA for version 0.8 right now is ASAP
                    Seriously, most functionality is completely finished and tested, so is a large part of the new documentation system. The one thing we're working on right now is a restructuring of the project itself which will enable us to more easily include or exclude the extension modules (cairngorm, puremvc, etc).
                    These extensions were released separately from a convenience point of view but we've noticed that for a lot of users it was confusing to see which functionality came from where, or how to compile them from the SVN sources.
                    With a refactored structure that will contain one centralised maven build file we hope to be able to tackle this problem.
                    Restructuring a project is never trivial, so naturally this takes a bit of time and since this is an OS project and we are dependent on people who perform these tasks in their spare time, I can, unfortunately, not give you a more specific answer than: As soon as possible.
                    Or even more generalized, its ready with its ready

                    Seriously, I know Martino is working his ass off, but it'll all be worth the wait If you really want the new functionality immediately you can always check out the entire project form SVN and make your own build with the existing maven pom.

                    cheers,

                    Roland

                    Comment

                    Working...
                    X