Home > Development > features
Anatomy of an Enterprise Flex RIA Part 2: Running the Sample Code
To run the sample code you need to do a little preparation:
- 1. Create a database called bookie.
- 2. Unzip enterprise-flex-code.zip to a working directory.
- 3. Unzip m2_repository.zip and copy the contents into ${user.home}/.m2/repository.
On a Mac, this should be in /Users/<your username>/.m2. On Linux, this should be in /home/<your username>/.m2. On Windows, this will be in C:\Documents and Settings\<your username>\.m2.
Edit the properties files in the working directory for your system:
In
Run maven build: At a command prompt in the root of your project, run `mvn package`.
Run ant deploy: At a command prompt in the root of your project, run `ant dev-deploy`.
- 1. Start JBoss.
- 2. Point your browser at http://localhost:8080/bookie.
- 3. Log in with card number 123456.
- 4. Try out the application!
Our Project: Bookie
Introducing Bookie
Our project is for an imaginary online book reservation application called Bookie. This application will be a self-service system for a hypothetical library. It will allow a user to log in with a library card number, search for books, and reserve them online so that by the time she gets to the library, the books will be ready for her to pick up.
It also allows library administrators to add and update information regarding authors and their books. While they’re working, they’ll also see automated notifications of new book reservations so that they can be prepared when a user shows up to get the book she reserved.
Use Cases
A use case, or user story, as mentioned earlier, describes the functionality we want our application to offer users. A use case highlights the functionality we need to include in our application, not just as raw functionality but also as proposed solutions to problems that users would like to have solved. You can think of a use case as a story that describes the way the user will use the application.
For instance:
“The user enters his shipping information, including state, and the system calculates the tax for that state."
Use cases don’t make technical demands explicitly, such as what kind of database schema to use or which language to use, nor do they use jargon or technical terms.
Table 1 and Table 2 list the use cases for Bookie. We’ll make them simple and condensed—simpler than they would be “in the wild"; just the titles, really. We have use cases that discuss both user and administrator stories.
| Table 1: user Use Cases | |
|---|---|
| USE CASE NAME | DESCRIPTION |
| Sign In | Users will sign in to the application with their library card number. This is all the authentication we’ll do in this simple application, but it will be enough to identify a user against whom we can save data in the database. |
| Find by Author | The user will be able to find all the books by a certain author. |
| Find by Subject | The user will be able to find all the books under a certain subject. |
| Find by Title | The user will be able to search for books by the book’s title. |
| Browse Authors | The user can browse a list of all authors. |
| Browse Titles | The user can browse a list of all titles. |
| Browse Subjects | The user can browse a list of all subjects. |
| Find Author | The user can search for a specific author by name. |
| Find Subject | The user can search for a subject by name. |
| Table 2: administrator Use Cases | |
|---|---|
| USE CASE NAME | DESCRIPTION |
| Create, Update, Delete Subjects | Administrators can manage all the subjects in the system. |
| Create, Update, Delete Books | Administrators can manage all the books in the system. This includes assigning the book, author, and subject. |
| Create, Update, Delete Authors | Administrators can manage all the authors in the system. |
| Create, Update, Delete Users | Administrators can manage all the users in the system. |
| Check Books Out | Administrators can manage the outstanding reservations and mark them checked out as they’re picked up. |
| Check Books In | Administrators can manage a list of checked out books, and check them in as they’re dropped off. |
This is a nice, small project with just a few use cases, which should let us get a sense of the process and use the tools we’ve learned without dealing with a lot of technical details. Each section that follows discusses a “layer" of the application. The layers build from the database to the data model to the service interaction to the user interface of the application, giving you a chance to study the technology used at each layer.
Next installment we'll start to break the project down and show how we'll use Maven to automate the process of building the project's code. You can always find the entire series here.


A little suggestion: it would be good to have a simple example of the command for the "1. Create a database called bookie." It would be very useful for the non-DBA specialists, who won't spend a lot of time working with DB, but just needs it to get application running.
Use cases explanation — very good and clear. I like how consistently you're putting the material in the learning stream, waiting for next parts.
Good point Rostislav. I find the easiest way to create a database once you have mysql installed is to run this command from a console: `mysqladmin -u create `. Others may want to install a graphical client like the one here: http://dev.mysql.com/downloads/gui-tools/5.0.html.
Two other notes, I'm trying to get the links to the example files up here, so stay tuned with that.
Also, there seems to have been some HTML issues with the Maven paths. They should be as follows:
Mac:
/Users/*user name*/.m2
Linux:
/home/*user name*/.m2
Windows:
C:\Documents and Settings\*user name*\.m2
Tony, thanks for the corrections, I'm following the series.
Tony,
when I run "mvn package", i get build error ("failed to resolve artifacts"):
Missing:
----------
1) microcontainer.jboss.ejb3:hibernate-all:jar:rc9
...
2) microcontainer.jboss.ejb3:jboss-ejb3-all:jar:rc9
...
3) microcontainer.jboss.ejb3:thirdparty-all:jar:rc9
...
4) org.apache.db.ddlutils:ddlutils:jar:1.0-SNAPSHOT
...
----------
4 required artifacts are missing.
for artifact:
lcds.examples.bookie:bookie-data:jar:1.0-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
I went to look for the first 3 files but could not find them at
http://repo1.maven.org/maven2/microcontainer/ where it tried to download them from.
I am new to maven so I really do not know how to resolve this. Any input will be appreciated! :)
thanks
AAaah :D
It is all good! hehe
I had not extracted m2_repository.zip correctly.
Cheers
Just to give heads up...
After many unsuccessful attempts I finally got the application to successfully build and deploy. It definitely was a learning, hands on experience. Thanks for the little challenge, Tony! :P
A few points:
First, I commented out line 22 (parallel>true) in code/bookie-data/pom.xml. It was throwing java exceptions for some reason...
Second, I commented out line 16 to 25 in code/bookie-data/src/test/resources/testng.xml. This disables the "Functional Tests" for unit testing that was giving off all kinds of errors and preventing the successful build. I just really wanted to build it at this point, nothing more! :P
Third, in the m2_repository.zip file there was a wrongly named directory: com/adobe/flex should be com/adobe/flex2 ...
Fourth, in code/bookie-ui/build.xml I had to append ".exe" to "mxmlc" like "${flex.sdk.bin.dir}/mxmlc.exe" (lines 33, 47 & 61). Maybe I didnt install the flex sdk right, dunno whats the deal (I am running win xp)..
Unfortunately, although the procedure populated my bookie database, compiled sources files and deployed the output to the jboss server, after opening http://localhost:8080/bookie/ and entering 123456 as card number the app popped up a msg saying "Unable to sign in"?! bleh...I looked at the jboss output and it said that it couldnt establsh database connection..
grr :(
Followed Martin's suggestion and deployed succesfully, but when going to http://localhost:8080/bookie got the following error
Suggestions?
[MessagingError message='No service is configured to handle messages of type 'flex.data.messages.DataMessage'.']
at mx.messaging.config::ServerConfig$/getServiceIdForMessage()
at mx.data::Metadata()
at mx.data::ConcreteDataService()
at mx.data::ConcreteDataService$/getService()
at mx.data.mxml::DataService/set destination()
at lcds.examples.bookie.business::Services/_DataService1_i()
at lcds.examples.bookie.business::Services()
at index/_Services1_i()
at index()
at _index_mx_managers_SystemManager/create()
at mx.managers::SystemManager/initializeTopLevelWindow()
at mx.managers::SystemManager/docFrameHandler()
Finally, after digging deep..I managed to run the app successfully..jeje
What was missing was the jboss mysql connector. You can find info here:
http://wiki.jboss.org/wiki/Wiki.jsp?page=SetUpAMysqlDatasource
Also, do not set a password to the root account of the mysql server! I have not idea why this was messing things up but after removing the password even the Functional Unit Test seemed to run ok.
I am a total newbie regarding maven, mysql, and jboss but I got the application to run after sweating for a day! hurrah! :D
@Martin - that's good to hear. It sounds like I need some errata posted up here. Can you contact me at this email so I can figure out exactly what went wrong?
Excellet Article , Author gave the global insight into different flavours of technologies and how we can use these.
Hi Martin,
I could able to build and deploy the application on jboss , getting the same error "Unable to Sign In"
Could you please explain how you resovled the this issue ?
I have properly confgured the database connection ... Am I missing some thing ??
I will be waiting for the next part of the series....
Thanks,
Giridhar
Can somebody help me?
I get the following error when issuing the 'mvn package' commnad
load-schema:
[ddlToDatabase] Read schema file C:\Eclipse\flex_projects\code\bookie-data\src\d
ata\schema.xml
[ddlToDatabase] Database platform MySQL does not support database creation via J
DBC or there was an error while creating it: Database
creation is not supported
for the database platform MySQL
Feb 9, 2008 8:03:11 PM org.apache.ddlutils.platform.PlatformImplBase evaluateBat
ch
I dont know enough about MySQL or the DDLUtils.
I also get a build failure error because the tests did not all pass. Anybody else getting the same issue?
Thanks.
@Mihir
checkout the bookie-data build file. looks like mysql is not supported, thus the error. It creates the schema just doesnt populate the data. I Havent dug any deeper.
@Mauro
Did you ever figure this out? I am getting the EXACT same error.
Folks, make sure your root mySQL account does not have password...this is how it is configured in the properties files in a few places. (you can try and find them all but that will be more tedious :P )
For the people getting the above error: Ignore it! :D The reason is that it tries to create a database called bookie but this is either not supported or since you created the bookie db already in the first step, it throws an error when seeing it exists, obviously.
Also, data is put in the database when running the tests so if you cant pass the tests your database will stay empty...
Hope I helped! :D
@Mauro
you need to have fds.swc under /frameworks/lib directory.
dont forget ds_rb.swc under /locale/en_US either.
i am getting the below error while building the package. I have installed log4j using maven, after I was getting the error, but it did not help. Did anybody else hit a similar issue?
============================================
[INFO] Building Bookie Example Data Project
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [antrun:run {execution: ant-data-tasks}]
[INFO] Executing tasks
data-tasks:
[echo] Using Database at jdbc:mysql://localhost:3306/bookie
load-schema:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error executing ant tasks
Embedded error: The following error occurred while executing this line:
java.lang.NoClassDefFoundError: org/apache/log4j/Level
[INFO] ------------------------------------------------------------------------
[INFO] Trace
============================================
Ive been trying to get this to run for over a week now and keep getting the following. Has anyone resolved this?
[MessagingError message='No service is configured to handle messages of type 'flex.data.messages.DataMessage'.']
at mx.messaging.config::ServerConfig$/getServiceIdForMessage()
at mx.data::Metadata()
at mx.data::ConcreteDataService()
at mx.data::ConcreteDataService$/getService()
at mx.data.mxml::DataService/set destination()
at lcds.examples.bookie.business::Services/_DataService1_i()
at lcds.examples.bookie.business::Services()
at index/_Services1_i()
at index()
at _index_mx_managers_SystemManager/create()
at mx.managers::SystemManager/initializeTopLevelWindow()
at mx.managers::SystemManager/docFrameHandler()
I finally got my application to run. I had to make a few changes though.
1. Added the following line to build.xml under code\bookie-data.
Without this, the compile was failing, with the error in my previous post.
2. I had to provide the password for the mysql in jdbc.properties.mysql present under code\bookie-data.
3. Also followed Martin's advice(below) which i am pasting below
"
First, I commented out line 22 (parallel>true) in code/bookie-data/pom.xml. It was throwing java exceptions for some reason...
"
Hi Steve,
Do you have the below tools installed under your repository.
02/13/2008 09:38 PM flex-bootstrap
02/13/2008 09:38 PM flex-messaging
02/13/2008 09:38 PM flex-messaging-common
02/13/2008 09:38 PM flex-messaging-opt
02/13/2008 09:38 PM flex-messaging-req
I think you are missing the LiveCycle Data Services.
I've got the same problem like steve.
@ashok: do you mean the jar libraries in path C:\dev\tools\jboss\jboss-4.2.2.GA\server\default\deploy\bookie.ear\bookie.war\WEB-INF\lib ?
if yes.. i have those installed.
is there a fix for this error? I've not been able to resovle.... it seems that lcds are setup ok.
[MessagingError message='No service is configured to handle messages of type 'flex.data.messages.DataMessage'.']
at mx.messaging.config::ServerConfig$/getServiceIdForMessage()
at mx.data::Metadata()
at mx.data::ConcreteDataService()
at mx.data::ConcreteDataService$/getService()
at mx.data.mxml::DataService/set destination()
at lcds.examples.bookie.business::Services/_DataService1_i()
at lcds.examples.bookie.business::Services()
at index/_Services1_i()
at index()
at _index_mx_managers_SystemManager/create()
at mx.managers::SystemManager/initializeTopLevelWindow()
at mx.managers::SystemManager/docFrameHandler()
In case anyone got the Interface IBindingClient was not found error, you need to download the lastest flex sdk and copy the jars under lib directory in the zip and overwrite those in your flex sdk dir.
Anybody got this error "That card number was not found"?
I query the books table and people table, and both row counts are zero, there must be a sql script somewhere that inserts the data...
@Paul W - Running the tests should leave the sample data in the database, is this not what you're seeing?
Thanks Tony, whew! I finally got it working, what i found out was that, do not comment out the line 16 to 25 in code/bookie-data/src/test/resources/testng.xml, cos that have to do with inserting the data into the tables. And with that uncommented out, errors will be thrown becos i set a password for root login on mysql. so to reset the password, do a login to mysql, and do SET PASSWORD = PASSWORD('') to clear the root password, that will essentially fix all the problems.
Jboss is still throwing some exceptions, but i think those are related to jms queues table setup, which can be ignored i think.
I tried this tutorial a second time from 0 but at the end I received again the error:
[MessagingError message='No service is configured to handle messages of type 'flex.data.messages.DataMessage'.']
I have the all the flex jar files in the follwing 2 directories.
....jboss-4.2.2.GA\server\default\deploy\bookie.ear\bookie.war\WEB-INF\flex\jars
....jboss-4.2.2.GA\server\default\deploy\bookie.ear\bookie.war\WEB-INF\lib
Is this problem a jboss issue?.. Which JBoss version do you recommend?
Cyrill
"you need to have fds.swc under /frameworks/lib directory.
dont forget ds_rb.swc under /locale/en_US either."
But where to get them ?
With all the hoops and errors that everyone seems to have to address, why not update the article and files so everyone else new to the article won't have to fight their way through them???
Thanks to all who have posted various work arounds to the errors and incorrect files!
This is ridiculous! I've spent way too much time trying to get the app just to compile.
I'm running into the same problem as above re:
IBindingClient was not found error
I have the release version of Flex SDK 3, verified the paths and jar files. I still get the error. Did something change from the beta version of Flex 3 to the release that would prevent this from compiling?
@Steve: I had the same problem, use the v2.0.1 SDK to compile. Change the mxml.project.properties file to point to the right SDK, mine is:
flex.sdk.bin.dir=C:/Program Files/Adobe/Flex Builder 3/sdks/2.0.1/bin
I agree with Steve, I'm having lots of problems, specifically with the "No service is configured to handle.." issue. I hit a wall on that one...
Hello; I am having a problem with mvn package; actually the problem is with the ant task "compile-index" that gets called by maven.
If I execute ant compile-index in the bookie-ui directory I get the following error message:
C:\Temp\FlexExample\code\bookie-ui\build.xml:33: Execute failed: java.io.IOException: CreateProcess: C:\tools\flex3\bin\mxmlc -context-root /bookie -load-config C:\Temp\FlexExample\code\bookie-ui\src\main\bookie.war\WEB-INF\flex\flex-config.xml -services C:\Temp\FlexExample\code\bookie-ui\src\main\bookie.war\WEB-INF\flex\services-config.xml index.mxml error=193The mxmlc compiler is complaining about the index.mxml file.
Does nayone have any ideas?