Oct 14, 2008

Deploying a Flex Application to JBoss

Level of Difficulty: Face-Palm Easy (i.e. super simple)


Intro to the Intermediate Tutorial Series

When I first began learning Flex, the hardest hurdle I faced was that there weren't many "intermediate" tutorials. The tutorials I found were either very basic, or required the use of specific technologies or frameworks that I wasn't using. This series of tutorials will attempt to focus on just a one or two topics and cover those topics in something of a technology agnostic way. For example, I use ANT and FlexBuilder, but I will endeavor to write these tutorials such that you aren't required to know either.



Introduction
Most beginners start with flex by using FlexBuilder or the SDK + editor, where they write and run the applications locally on their hard disk. At some point you reach the stage where you are ready to migrate to an application server like JBoss. This tutorial will guide you on how to deploy a flex application to the JBoss server.

Process:
  1. Create application deployment area on JBoss server.
  2. Create & Build Flex application.
  3. Deploy Flex application outputs to application deployment directory.
  4. Start JBoss & Test

Assumptions:
  1. You know how to create and build a "hello world" flex application using Flex Builder, or whatever toolset you use.
  2. You have JBoss installed.




Step 1: Create Application Deployment Area on JBoss Server

The first step is to setup JBoss to handle the flex application you are going to create. Thanks to the niftiness of JBoss, all you need to do here is create a ".war" directory in the deployment directory.

Steps:
  1. Navigate to your JBoss deploy directory (e.g. "C:\Java\jboss-4.2.3.GA\server\default\deploy").
  2. Create a new directory that ends in ".war" (e.g. "SampleFlexApp.war")

Note: You could also package your web app into a ".war" archive file, or create the web application as part of an enterprise archive (.EAR file). For simplicity sake, however, this tutorial will deploy to a ".war" directory. Once you understand where flex fits in with regard to a WAR, there are countless existing tutorials on the nuances of EAR/WAR files.

Figure 1 - Creating a Deployment Directory in JBoss

Alternative: Using Ant
If you use ANT, it is common to create a "deploy" task in the build.xml of your application that creates these directories as part of the normal build. If you intend to deploy your application using ANT you can skip this step.


Step 2: Create & Build Flex Application
For this tutorial we will create a simple flex application that prints "hello world". Using your tool chain, create a new flex project named "SampleFlexApp" with the application file "SampleFlexApp.mxml" as shown below.

Figure 2 – Source for Sample Application

Alternative: Creating a J2EE Flex Project in FlexBuilder

Flex Builder allows you to create a new Flex project that is connected to an application server like JBoss and automatically deploy the application. For this to work you must have completed step 1, and created the “.war” directory in the JBoss deployment.
1. Create a new Flex project, select J2EE as the server and click Next.


Figure 3 - FlexBuilder New Project


2. Configure J2EE Server:
  • Web Root: Set the web root to the location of your ".war" directory you created in the JBoss deploy directory. (E.g. "C:\Java\jboss-4.2.3.GA\server\default\deploy\SampleFlexApp.war")
  • Root Url: Set the root url to http://localhost:8080/"App directory minus the .war" (e.g. http://localhost:8080/SampleFlexApp).
  • Validate Configuration: Press the Validate Configuration button to verify that you have this setup right. You will need to have JBoss running at the time.
  • Output Folder: This defaults to a "debug" directory. I typically remove this and have it deploy to the main directory (E.g. "C:\Java\jboss-4.2.3.GA\server\default\deploy\SampleFlexApp.war"). This way I don't have to have a "debug" in the URL I visit.



Figure 4 - Configure J2EE Server in FlexBuilder


Having setup your Flex Builder project as a J2EE project, it will now automatically deploy to the directory of your choice every time you make changes or try to run the flex application.

Step 3: Deploy the Flex Application

To deploy your flex application it is simply a matter of copying your compiled flex outputs to the “.war” directory you created in the JBoss deploy directory. After copying your “.war” directory should look similar to the figure below.



Figure 5 - WAR directory after deploying Flex Application
JBoss is great because it “hot deploys” anything with a “.war” extension. So simply copying your files here causes JBoss to investigate and load up your application.

Alternative: Deploy Using a J2EE Flex Project in FlexBuilder

If you created a J2EE Flex Project in step 2, you can skip this step because Flex Builder will automatically copy over the appropriate files tot the specified deploy directory.

Alternative: Deploy Using ANT

If you are an ANT user, it is a pretty trivial task to create a deploy target that copies these files to your deploy directory.

Step 4: Start JBoss and Test

To run your application from JBoss simply start the JBoss application server by excuting the run.bat or run.sh script in the “JBOSS_HOME/bin/” directory.
Now open your web browser and go to the URL http://localhost:8080/SampleFlexApp/SampleFlexApp.html

Summary

Although I tried to be overly detailed in this tutorial, it really comes down to copying your build files to a “.war” directory in the JBoss deploy directory structure. JBoss does the rest.



24 comments:

Anonymous said...

You're the man. Thanks a lot for this very helpful tip... To anybody referencing this blog, pay close attention to the screen shots when using the eclipse wizard to create a Flex J2EE project. Be sure to uncheck the options that are demonstrated to be unchecked. Otherwise, you won't get the windows that you expect. It worked for me on Ubuntu 9.10, JBoss 5, flexbuilder 4 linux

Anonymous said...

Quick follow up regarding my jboss 5.1.0 environment: I did download the Adobe BlazeDS turnkey distribution to get the following jars, which I added to my server/default/lib directory:

flex-tomcat-common.jar
flex-tomcat-server.jar

Also, from the same distribution, I added the following valve entry to my server/default/deploy/jbossweb.sar/context.xml file:

Anonymous said...

Valve entry:

(open bracket)
Valve className="flex.messaging.security.TomcatValve"
(close bracket)

George said...

I AM trying to follow this tut but there are no figures/pictures. I just don't see any.....
Where are they? Could you re-post them?
Thanks

Reham said...

Thanks for your post, it helps me a lot. but still have a problem in the connection between Adobe Flex and Hibernate (RESTFul Services).
I really appreciate any help you can give while you have an experience.
There is no error or an exception. Please if you have time to take a look to the codes. or if you know someone can help please email me To: reham.saud@hotmail.com

Thanks,

Juane Weg said...

rolex watches for sale
coach wallets
air jordan official site
michael kors handbag
girls jordans
columbia
converse outlet
michael kors factory outlet
nike huarache
timberland shoes
cheap jordan shoes
air jordan 13
fitflop clearance
michael kors
coach purse
michael kors outlet 90% off sale
joes new balance outlet
ralph lauren polo
coach handbag
supra for sale
ugg boots on sale 70% off
north face outlet store
oakley eyeglasses
north face outlet store
reebok shoes
cheap coach purses
michael kors outlet
vans shoes
michael kors wallet
christian louboutin shoes
columbia outlet store
salvatore ferragamo belt
coach factory
fitflop shoes
nike outlet
fitflop shoes sale
hermes bag
cheap jordan 11
michael kors factory outlet
michael kors purses sale
new balance shoes
michael kors factory outlet
rayban sunglasses
20160423yxj

Hua Cai said...

mulberry handbags
tory burch outlet online
tiffany jewelry
swarovski crystal
mulberry outlet
true religion uk
tiffany and co jewelry
prada outlet online
burberry outlet store
adidas trainers
nike air max
longchamp handbags
beats by dr dre
kobe shoes
nike air max 90
ferragamo outlet
true religion jeans
oakley sunglasses
ray ban sunglasses
camisetas futbol baratas
basketball shoes,basketball sneakers,lebron james shoes,sports shoes,kobe bryant shoes,kobe sneakers,nike basketball shoes,running shoes,mens sport shoes,nike shoes
timberland boots
michael kors handbags
mulberry handbags sale
tiffany jewelry
true religion sale
michael kors online outlet
christian louboutin outlet
true religion outlet
true religion jeans outlet
true religion jeans
air jordan shoes
christian louboutin online
jordan pas cher
michael kors uk outlet
20160528caihuali

xumeiqing said...

20160620meiqing
omega seamaster
cheap jordan shoes
tiffany and co
gucci outlet
ralph lauren outlet
rolex submariner
true religion
michael kors outlet
michael kors outlet clearance
fitflops
nike store
longchamp handbag
nike air max
converse uk
louis vuitton outlet
polo outlet
jimmy choo outlet
adidas supercolor
ed hardy uk
oakley sunglasses
nike air max
instyler max
jordan shoes
nike air force white
ray ban outlet
louis vuitton outlet
kobe shoes
toms
michael kors outlet
prada outlet store
adidas stan smith
ralph lauren outlet
fitflop uk
true religion outlet
adidas trainers
cheap nba jerseys
nfl jerseys wholesale
louis vuitton factory outlet

xjd7410@gmail.com said...

kate spade
nike air max 90
louboutin shoes
tod's shoes
louis vuitton handbags
true religion jeans
retro jordans 13
oakley sunglasses
coach outlet store online
gucci handbags
cheap oakley sunglasses
nike roshe run women
gucci outlet online
burberry bags
michael kors outlet
marc jacobs handbags
louis vuitton outlet
coach factory outlet online
nike free run
coach outlet store online clearances
coach factory outlet
kate spade handbags
oakley outlet
oakley sunglasses
coach outlet store online
michael kors outlet
oakley sunglasses
adidas nmd
adidas yeezy
louis vuitton outlet
chenyingying712

dong dong23 said...

christian louboutin shoes
michael kors outlet
chicago bulls jerseys
hermes outlet
ray ban sunglasses
adidas superstar
longchamp outlet
coach factory outlet
fitflops sale clearance
cheap jordans
201610.6wengdongdong

raybanoutlet001 said...

michael kors handbags
yeezy boost 350 white
michael kors handbags
gucci sito ufficiale
michael kors handbags
supra shoes
michael kors outlet
chaussure louboutin pas cher
dolce and gabbana shoes
nike huarache

raybanoutlet001 said...

yeezy boost 350 white
patriots jerseys
cowboys jerseys
the north face outlet
michael kors outlet
gucci borse
ravens jerseys
converse shoes
hugo boss outlet
air jordan uk

dada24 Xu said...

kate spade outlet
michael kors outlet canada
timberland shoes
abercrombie
christian louboutin shoes
chaussure louboutin
cheap jordan shoes
true religion jeans outlet
polo ralph lauren outlet online
nike air huarache
zhi20161209

dong dong23 said...

gucci outlet
ralph lauren outlet
moncler uk
coach outlet store online
ralph lauren outlet
beats by dre
michael kors outlet
ugg boots
ralph lauren uk
seattle seahawks jerseys
201612.27wengdongdong

Meiqing Xu said...

birkenstocks
levis outlet online
louis vuitton handbags
coach factory outlet
true religion
fitflops
red bottoms shoes
christian louboutin shoes
fake rolex
toms outlet
20170209CAIYAN

Arun Kumar said...

I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Alfresco , kindly contact us http://www.maxmunus.com/contact
MaxMunus Offer World Class Virtual Instructor led training on Alfresco. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us:
Name : Arunkumar U
Email : arun@maxmunus.com
Skype id: training_maxmunus
Contact No.-+91-9738507310
Company Website –http://www.maxmunus.com


Anonymous said...

friv 3

Anonymous said...

friv

Anonymous said...

friv

Anonymous said...

friv

Anonymous said...

friv

Anonymous said...

friv

Anonymous said...

yepi online

LCc 03 said...

cheap jordans
nike air force 1
adidas neo
adidas nmd
nike air force
nike air force 1
links of london
lebron james shoes
air jordan shoes
longchamp le pliage