Tag: Flex

MessageBroker already defined

I got this exception yesterday, when I tried to deploy two Flex applications using Blazeds on JBoss 5.1. The first deployment went fine, but number two deployment threw this:

java.lang.RuntimeException: MessageBroker already defined from MessageBrokerServlet with init parameter messageBrokerId = '__default__'

It happens because both .ear applications were deployed in the same domain. One way of solving this is by giving the MessageBroker servlets a unique identifier. That works, but it’s probably better to create a proper class isolation by giving both apps their own domains. Read my blog about class isolation in JBoss.

The class isolation solution is simple. Just add a jboss-classloading.xml file at /EarContent/WEB-INF. The file should look like this:

<classloading xmlns="urn:jboss:classloading:1.0"
name="yourApp.war"
domain="yourAppDomain"
export-all="NON_EMPTY"
import-all="true">
</classloading>

After two redeployments the web applications should now inhabit their own domains. I use the .ear application name as the domain naming scheme.

I compiled open source Adobe Flex SDK 3.5.0.12683 on Windows the other day – and today did the same thing on my MacBook. Since the journey from source to jar file was rather convoluted, I decided to document all the steps. Also my steps differ a bit from the recommended steps.

First download the Open Source Flex SDK 3.5.0.12683. Do not be tempted to download the zipped file from the webpage. A much needed file, setup.sh, is not present in that particular package. Funny that. Instead use svn. To install svn just enter:

sudo port install subversion

Then create the directory you want to use for Flex and cd it. To checkout the SDK source type:

svn co http://opensource.adobe.com/svn/opensource/flex/sdk/tags/3.5.0.12683

After waiting for svn to finish you should now have all the source code. Next you’re ready for the editing of setup.sh. It’s located at the root of your downloaded SDK source. Open the file (I used aquamacs but you can use your favorite editor) and point the script in the right direction of your ANT_HOME folder and your JAVA_HOME folder. I keep the two environment variables in my .profile by the way.

If you don’t have Ant, you’ll need to download and install it as well. Ant on OS X 10.6.2 is easily installed like this. Finally save your changes of setup.sh.

Next tell the Terminal all about the required paths for the coming ant build by issuing this:

source setup.sh

Now you’re almost ready to run the ant build. But before you do, you have to make sure that the Flash tests at the end of the ant build work properly. They also look rather impressive, I might add, so it’s a bad thing to miss. For testing, the Flash Player’s mm.cfg file must have the following entries

ErrorReportingEnable=1
TraceOutputFileEnable=1

and a FlashPlayerTrust file must allow local SWFs to access local files.

To ensure this, copy the files from Adobes to-do. I had to use “/User/myuser/” instead of just “/” to get the tests to work without a security sandbox violation.

That’s it! The Terminal is ready for the ant build. Do a:

ant main checkintests

and watch the build fireworks. You now have a complete mxmlc open source environment. Use it to compile some SWFs.

I needed swfdump.jar on my Windows box today. Per default the file is not in the bin folder of Adobe Flex SDK 3.5.0.12683 – so I discovered that I had to build the file all the way from source. Since the journey from source to jar file was rather convoluted, I decided to document all the steps. Also my steps differ a bit from the recommended steps.

First download the Open Source Flex SDK 3.5.0.12683. Do not be tempted to download the zipped file from the webpage. A much needed file, setup.sh, is not present in that particular package. Funny that. Instead use svn (if you don’t have a command line edition of subversion, I recommend Sliksvn). Create the directory you want to use for Flex and cd it. To checkout the source type:

svn co http://opensource.adobe.com/svn/opensource/flex/sdk/tags/3.5.0.12683

After waiting for svn to finish you should now have all the source code. Next you need to install cygwin. Since you’re on a Windows box, you’ll need cygwin to run the setup.sh script. Can’t be done without it. So get cygwin setup.exe and do a standard installation. I installed nano as an easy editor as well.

Now you’re ready for the editing of setup.sh. It’s located at the root of your downloaded SDK source. Open the file (I used nano but you can use your favorite editor) and point the script in the right direction of your ANT_HOME folder and your JAVA_HOME folder. If you have neither, you’ll need to download and install Ant and Java SDK as well. Finally save your changes of setup.sh.

Next tell cygwin all about the required paths for the coming ant build by issuing this in cygwin:

source setup.sh

At this point I got an error: $’\r’: command not found. Apparently cygwin is getting halted by dos carriage returns in the script. But don’t worry. To remedy this, you issue the line:

dos2unix setup.sh

Now you’re almost ready to run the ant build. But before you do, you have to make sure that the Flash tests at the end of the ant build work properly. They also look rather impressive, I might add, so it’s a bad thing to miss. For testing, the Flash Player’s mm.cfg file must have the following entries

ErrorReportingEnable=1
TraceOutputFileEnable=1

and a FlashPlayerTrust file must allow local SWFs to access local files.

To ensure this, copy the files from Adobes to-do.

That’s it! The cygwin enviroment is ready for the ant build. Do a:

ant main checkintests

and watch the build fireworks. The swfdump.jar file is now to be found in the /lib folder. And as a benefit you also now have a complete mxmlc open source environment. You can use it to compile some SWFs.

Flex and architecture

Since Design Patterns by Eric Gamma et. al. came out an extra layer of architecture and structure has been imposed on object-oriented programming, and various ways of incorporating the ideal design patterns have emerged over time. This applies to Flex and Actionscript as well: Two of these different flavours are called Cairngorm and PureMVC.

But sometimes, I’m just saying sometimes, especially when dabbling in small projects, the work and investment needed is simply too big. I just found a good post, that goes right to the heart of the Model – View – Controller design pattern. It really demonstrates that good architecture is possible without too much overhead.