Tagged: springas

Upgrade to Spring AS 0.8 and others

The Spring Actionscript project is maturing and as they do, they keep teasing apart the entire project. So I am now upgrading from 0.7 to 0.8 and if you are to, here is what you can expect. (change log here)

a) If you were using the older AS3Reflect library, well now they moved that again over to as3commons.reflect. Also note that the ClassNotFoundError which used to be in AS3Reflect has now moved to as3commons.lang. The have been factoring out a lot of stuff, however Spring AS still is dependent on these new libraries so you must download those SWCs and link them in.

b) Looks like as3commons now has a logging package, ugh, yet another! I already have support for Spicelib logging as well as the default Flex logging framework built into my framework, so I guess I might need to take a look at the new as3commons logging to see if I will create an adapter for that.

c) If you are still referencing the older Prana Framework xml schemas in your xmlns declaration (in applicationContext.xml) you will need to update those to use the new schema location over at springactionscript.org. It should look like the below:

<pre><?xml version="1.0" encoding="utf-8"?>
    <objects xmlns="http://www.springactionscript.org/schema/objects"

d) as3commons.reflect now dumps traces of errors during the pre-instantiation phase for all singletons. This seems to occur for objects who’s constructor expects a non-null parameter, but the reflect code is passing NULL for all parameters. In my case, my app comes up A-OK and functions fine, however if you are running in debug mode you will see all this trace output from as3 reflect.

e) lastly, if you have any sort of a build script, in my case a Groovy GANT script, make sure to update those for the new library dependencies.

Those are the only items I really ran into when upgrading. All my FlexUnit tests passed A-OK so it looks like I am good to go. Good luck.

Also check out the Spring AS docs located here

It looks like since I last looked, they added quite a few new interested features:

a) They fixed the import issue finally, now you can import other XML files as well as import them if they are embedded in your app

b) You can define your app context “xml” within MXML directly inline your Flex app which may be of use

c) Yea! the  “” (blank) value in a value declaration is fixed.

Spring AS & Prana woes with blank prop or constructor args

UPDATE: The bug described here appears to be fixed as of 0.8

So I’ve been doing a fair amount of work with Spring Actionscript v0.7.1 (formally the Prana Framework). In AS3 you can define methods and/or constructors that take optional arguments. Optional arguments must always be defined after the required arguments and they are noted by the presence of a default value in the method/constructor signature as such:

package my {
   public class MyClass {

      public function MyClass(reqArg1:String, opArg1:Boolean=false, opArg2:String=null):void {
         // your constructor code for MyClass here;


When you are defining a bean in Spring AS you can define it’s constructor arguments as so:

<object id="myClassInst"       class="my.MyClass"       scope="prototype">                          <!-- required arg 1-->   <constructor-arg value="val4ReqArg1"/>   <!-- pass false for optional boolean arg 2 -->    <constructor-arg value="false"/>    <!-- intentionally pass BLANK to 3rd optional arg -->    <constructor-arg value=""/></object>

Well when running this  you will get an error like this for the 3rd argument:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at org.springextensions.actionscript.ioc.factory.xml. parser.support.nodeparsers::KeyValueNodeParser/parse()
at org.springextensions.actionscript.ioc.factory.xml. parser.support::XMLObjectDefinitionsParser/parsePropertyValue()
at org.springextensions.actionscript.ioc.factory.xml. parser.support::XMLObjectDefinitionsParser/parseProperty()
at org.springextensions.actionscript.ioc.factory.xml. parser.support::XMLObjectDefinitionsParser/parseProperties()

This is a bug in Prana (see here http://jira.springframework.org/browse/SESPRINGACTIONSCRIPTAS-49), to get around this until it is fixed, you will need to pass some dummy value, that your constructor code will interpret as a BLANK, such as literally the string “BLANK”. Stupid? Yes, but until this is fixed in Spring AS this is the solution unfortunately!

Strange IMPORT failure in Spring AS

So I’ve started to think about splitting up the main applicationContext.xml file in one of my projects. The current one is getting quite large. Spring AS has the ability to import bean/object definitions from another XML file of your choice such as the following example where my context defines one object “yObject” and then declares an import to bring in another XML file which contains further object definitions:

  <object id="yObject" class="my.package.YObject"/>
  <import file="subConf.xml"/>

The contents of “subConf.xml” file look as follows:

<object id="zObject" class="my.package.ZObject"/>

After booting up Spring AS, I can successfully retrieve “yObject” however “zObject” is null. I have also tried specifying the subConf.xml file explicitly via a full path to no avail. I’ve been following the docs to the tee and this simply has made no sense! So after hours of fiddling with this and going through debugging the source code for Prana directly I found that when the following header that is in the objects tag the e4x “xml.descendants(“import”)” call within XMLObjectFactory._addImportLocationsIfAny() yields zero results.

<objects xmlns="http://www.pranaframework.org/objects"

When I remove all the xmlns/schema info OUT of the tag. The xml.descendants(“import”) works fine. Huh? Seems like an e4x bug?

[UPDATE 1/24 this is now fixed in the Prana source in SVN]