Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS

Whenever I work on a Flex project with Java backend I create a project in Flex Builder that combines Java and Flex. I find that this is the easiest way to work even if I don’t touch at all Java code and I just mess around with Flex/AS files. This is one piece of news brought by Flex Builder 3.

What advantages do you have using this setup? You can edit/run/debug both Java and Flex files in the same editor and same project; you can see the changes as soon as you save the modified files.

Let’s see what you need and how you can create a combined Flex/Java project with or without LiveCycle Data Services or BlazeDS.


Installing WTP (Web Tools Project)

In order to be able to create the combined project you need to have installed WTP (Web Tools Project – this is an open source Eclipse plugin that adds J2EE capabilities into Eclipse). If you start the New Flex Project Wizard and select J2EE from server technology and you don’t see the option “Create combined Java/Flex project using WTP” it means you need to install it.

For this you go to Help > Software Updates > Find and Install… Then select “Search for new features to install” and click Next. You should see something like this (select Europa Discovery Site) :

After this you follow the dialog screens and at some point you will see this screen (you press the “Select Required” button and Next, Next, Next and Finish):

Possible problems installing WTP in Flex Builder: sometimes although you have installed WTP you don’t see the option “Create combined Java/Flex project using WTP”. The solution is simple: type in a console the path to the eclipse executable and add “-clean” option; for my machine this command looks like: “c:eclipseeclipse.exe -clean”. After this you should be good to go.

Create the combined Java/Flex project

Let’s open the New Flex Project wizard and select from “Application server type” combo-box “J2EE” and make sure that the option “Create combined Java/Flex project using WTP” is checked (check the first image from this post if you need help). If you want to create a project that is using LCDS (LiveCycle Data Services) or BlazeDS you need to check “Use remote object access service”. Click “Next” and you see this page:

In the second page of the wizard you need to pay attention to “Target runtime”. WTP has a wonderful feature: you can configure your local J2EE server using a simple wizard and then Eclipse can deploy your application and can start/stop/republish the application on this server; all of these are happening from within Eclipse. This “Target runtime” is exactly what this thing does: it lets you associate your project with an already defined server or to define a new one. Click on the “New” button and you will see this wizard:

WTP supports the following J2EE servers: Tomcat, JBoss, WebSphere, JOnAS4, Oracle OC4J Standalone. From my experience the best for developing is the Tomcat: it is the fastest in terms of starting/ restarting/ redeploying. After you selected the desired server click “Next”.

In the second page of the wizard you need to browse for the server installation folder:

Click “Finish” and we are back to new Flex Project wizard. We select the target runtime from the combobox. If you choose on the first page to use LCDS, then on this page you need to browse for the path to Flex WAR file: if you want LCDS you should look for the file lcds.war under the installation folder and if you want BlazeDS you should look for blazeds.war under the blazeds folder. With this we are done and we can click “Finish”.

Once the project gets created you can play with the perspectives and change between Flex perspective and Java or J2EE perspective:

Run the project

So we have the project. Let’s see how can we run it. As I said before, WTP make this task child’s play. First thing we need is to be sure we have “Server” view displayed (if not you go to Window > Other Views… and select Server from the tree).

The first time you want to run a project you need to associate the project with the server – you do this only one time. You just right click inside the Flex application file and choose from the contextual menu Run As > Run on Server option:

This command will open this little wizard (you select the previously defined server and then click “Finish”):

After this the project gets compiled, the server is started and the project is deployed. At this point if you are looking inside the Server view you should be able to expand the Server node and see that a child exists with the same name as the project and the status of the server should be Started and Synchronized:

Now every time you change something in your project as soon you build the project, the project is redeployed automatically. And when you want to see the Flex application you choose Run As > Flex Application (the default browser is opened with the Flex application inside). Also because the project is associated with the server you can use the top right buttons from the Server view to start / stop / debug / publish.

This is it. In my next post I will talk about debugging Java and Flex code using this type of project.

Comments

75 Responses to “Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS”

  1. 1. Debugging a combined Java/Flex project : Mihai CORLAN on June 6th, 2008 11:45 am

    [...] my previous post I described how you can install WTP in Flex Builder and how you can create a combined Java/Flex [...]

  2. 2. Adding a Flex Nature to an existent Java (WTP) project : Mihai CORLAN on June 7th, 2008 6:24 am

    [...] Neither do I (If you want to create a new Java/Flex project then check the my previous posts about creating a Java/Flex project and debugging this [...]

  3. 3. jyothi on June 13th, 2008 1:04 pm

    Very good

  4. 4. Mihai Corlan on June 13th, 2008 11:34 pm

    thanks :)

  5. 5. Dr Flex & Dr LiveCycle » What is the preferred LiveCycle Data Services development environement on June 18th, 2008 2:24 pm

    [...] Flex Builder and add the WTC plugin.  Mihae Corlan has described the second option. In his post you can also find how to create a combined Flex/J2EE project and how to add the Tomcat [...]

  6. 6. Miti’s Blog » Blog Archive » AS and Flex Project trick on July 4th, 2008 9:19 am

    [...] trying to use the FDS AJAX Bridge to push some messages in an AJAX grid. So I’ve created a Flex + WTP + BlazeDS project and went to change the default Application from the default MXML file to my FDMSBridge.as [...]

  7. 7. SQLAssembler: create a Flex and Java application with LCDS (LiveCycle Data Services) without server side code : Mihai CORLAN on July 8th, 2008 7:05 pm

    [...] can download it for a trial from here; if you don’t have WTP installed, then check my article here; finally if you don’t have LCDS, you can download it from here. I use a combined Flex and [...]

  8. 8. Confluence: PereCEP on July 30th, 2008 6:49 pm

    FlexLCDSDemo…

    Intro The notes below should explain how to demo a Flex client using LiveCycle Data Services. Prerequisites You should have Tomcat (or other JEE web server) and ActiveMQ installed…….

  9. 9. David on August 7th, 2008 4:29 am

    Can you please write something about how to export a WAR file of the combined project? In eclipse, when doing a export/war the entire source code of flex is being added to the war file (even if you uncheck “Export source files”)

    Other than that – excellent articles and thanks a million!

    David

  10. 10. Mihai Corlan on August 7th, 2008 10:48 am

    @David

    There is a trick you can do. Just open the the file .settings/org.eclipse.wst.common.component from your project and comment the node with the attribute source-path=”/flex-src”.

    This should solve your problem.

  11. 11. Criando um projeto Flex/Java + BlazeDS no Eclipse | Vítor Avelino on August 17th, 2008 5:17 pm

    [...] Creio que ficou claro como criar um projeto Flex/Java + BlazeDS no Eclipse. Futuramente irei postar um outro tutorial ou screencast com um exemplo de comunicação Flex/Java. Este tutorial foi feito baseado nesse post. [...]

  12. 12. Frank on August 29th, 2008 8:25 pm

    Merci, this helped a lot!

  13. 13. name on September 1st, 2008 4:58 am

    Hello!,

  14. 14. name on September 1st, 2008 8:51 am

    Good day!,

  15. 15. Khoa on September 11th, 2008 4:53 am

    Hi David,

    Would you please give me direction on how i can deploy both java and flex in one go. Flex and Java is deploy in weborb and weborb is then deploy in tomcat. What will be the setting for the J2EE server? Should i point to Weborb or the tomcat server?

  16. 16. Miti’s Blog » Blog Archive » AS and Flex Project trick on October 15th, 2008 1:07 pm

    [...] ago I was trying to use the FDS AJAX Bridge to push some messages in an AJAX grid. So I created a Flex + WTP + BlazeDS project and went to change the default Application from the default MXML file to my FDMSBridge.as [...]

  17. 17. Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS | WOWWW! on November 12th, 2008 2:02 pm

    [...] Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS [...]

  18. 18. prakash S on November 20th, 2008 10:01 am

    with flex builder 3 build-3.0.194161 i am not able to update WTP.

  19. 19. Mihai Corlan on November 20th, 2008 5:51 pm

    @prakash S

    Thank you for telling me. Could you log a bug at http://bugs.adobe.com ?

    many thanks!

  20. 20. Francesco Paolo Schiavone on November 25th, 2008 2:38 pm

    thanks! this tutorial has been really useful to me! seems like preparing Flex+Java is harder than actually building applications with those.

  21. 21. Mihai Corlan on November 25th, 2008 4:25 pm

    @Francesco Paolo Schiavone

    I wouldn’t go so far :D
    Thanks!

  22. 22. Santhosh on December 17th, 2008 8:21 am

    Very nice. It is too much helpful. Appreciate your effort.

  23. 23. Komal on December 18th, 2008 9:43 am

    Thank You Very much !! :-)

  24. 24. lihua on December 30th, 2008 5:03 am

    Thank you a million for the doc. But I could not browse my Flex-J2EE application “table2.mxml” with LCDS2.6.1 and Flex builder3.0.1.205647.I use tomcat6.0.18 as my J2EE server. but I can just got ‘XML’ document instead of the compiled swf application when I submit “http://localhost:8080/J2EE2/table2.mxml”. It seems that “table2.mxml” are not compiled to swf application on the server side.
    Can you give me a hand?

  25. 25. Mihai Corlan on December 30th, 2008 11:10 pm

    @lihua
    I think the application file wasn’t created with the wizard new MXML application. Other than this, I don’t see any problem. Are you sure you have a project that has both Flex and WTP natures?

    Good luck!

  26. 26. lihua on December 31st, 2008 8:11 am

    Hi, Mihai,
    Yeah, I have a project that has both Flex and WTP natures. And now I have solved the problem. It is the problem of LCDS2.6.1. I uninstalled it and install LCDS2.5.1. Everything is OK now. With LCDS2.6.1, I could not access .mxml on server directly.
    Thank you so much.

  27. 27. drb on January 12th, 2009 6:42 pm

    thank you so much Mihai

  28. 28. Cornel Creanga » Blog Archive » BlazeDS, LCDS and integration with existing application on January 27th, 2009 1:57 pm

    [...] in so many places so I don’t want to insist on that – take a look for example at my colleague post. Instead I will write what to do when you already have an application packaged as WAR and you [...]

  29. 29. Developing a Flex WebService client « My experiments with technology on February 3rd, 2009 6:57 pm

    [...] Web Tools Project Eclipse plugin (Extremely useful tool to do simultaneous Flex and Java development. Installation instructions are available here  [...]

  30. 30. h2t on February 5th, 2009 2:05 am

    This is good as the war file is automatically generated whenever the code is changed. Is there a way to specify war file name as it is .war?

  31. 31. shanti on March 4th, 2009 2:09 am

    Hi,

    In this kind of java+flex project will the FlexBuilder compile the java source files or oes it need another script for compilation?

    Thanks

  32. 32. Mihai Corlan on March 4th, 2009 10:34 am

    @shanti

    java files are compiled by JDT (Java Development Tools) plugin. Flex Builder doesn’t have any compiler for Java. JDT is part of the WTP installation.

  33. 33. shinigami00 on April 1st, 2009 7:31 pm

    Hi i’m trying to export a flex/J2EE application as a release build but it generates me an error “An error has occurred. See error log for more details.java.lang.NullPointerException”.

    Please can you help me.

  34. 34. Mihai Corlan on April 1st, 2009 10:40 pm

    @shinigami00

    I have no idea what could be wrong. Maybe you can have a look on the forums, or submit/check a bug on http://bugs.adobe.com for Flex Builder.

    PS. fun of Bleach? :D

  35. 35. shinigami00 on April 3rd, 2009 1:31 pm

    Thnks anyway. I just exported my application as a .war file and deployed it in my SSL/Tomcat server and it’s working fine. no need to export it as release build application.

  36. 36. Meysam on April 23rd, 2009 10:39 pm

    Plsssss help me people…. it made me depress!

    how to install WTP (Web Tools Project) on Flex Builder 3???? How???

    i can not even install “Web and JEE Development” from the Hepl-find and install-search for new feutures… the error is: ” Eclipse XML Editors and Tools (2.0.2.v200802150100-7A1ECMCnbcl1bVs9uNm_Zkieb7Qe) requires plug-in “org.eclipse.emf.common (2.2.0)”, or compatible.”

  37. 37. Cristi on April 28th, 2009 2:10 pm

    @Meysam

    After you select “Web and JEE Development” and press “Select required” you will have automatically selected all the required plug-ins (do not uncheck anything!), all you have to do is to press the Next button.

  38. 38. Meysam on May 3rd, 2009 12:09 pm

    Cristi thanks!!!! i got it! thanks!!!!!

  39. 39. Software necesar pentru seminarii : Despre Adobe Romania on May 18th, 2009 12:34 pm

    [...] ar fi mai usor sa lucrezi cu LCDS daca iti instalezi si WTP in Flex Builder: [...]

  40. 40. Robin on May 19th, 2009 10:05 am

    Dear Sir,
    I followed the instruction as you said. I worked in the part of creating project.
    But when i run the project it simply says cannot find the resources. i manually started the tomcat server as well as i let be down automatically from the flex.
    Do i need to change something in the web.xml file.
    Please help me

    Your’s
    Robin Thapa

  41. 41. Robin on May 19th, 2009 10:08 am

    Opps im sorry for my mistake,
    Hahahahah finally it worked, i read ure tutorial once again and i corrected my mistake.
    Thank you for your kind help

  42. 42. Mihai Corlan on May 20th, 2009 12:26 am

    @Robin

    Can you post what you did wrong? Just to help others that may do the same thing…

  43. 43. Robin on May 22nd, 2009 8:38 am

    Dear Sir,
    i completed the set up as you have described above and its working.
    But i cant compile my java class from flex builder3.
    Can you put a tutorial as how to simple write a simple java class and display a string return from the java class to the browser using flex.
    Please help me, i am interested in learning flex.
    I hope you get what i said?My English is poor.

    Thank you,
    Robin

  44. 44. Mihai Corlan on May 22nd, 2009 9:57 am

    @Robin

    take a look here: http://www.adobe.com/devnet/flex/flex_java.html

    you should find what are you looking for.

  45. 45. Jason on June 1st, 2009 10:18 pm

    Thanks For your help ,
    It worked for me !!

  46. 46. Jason on June 1st, 2009 10:20 pm

    I can say Java -Flex is the best combination among all others …

  47. 47. Mejat on June 9th, 2009 2:01 pm

    Hello

    Thanks for give idea about configure flex and java project.But one important things is how The Add/remove project option is enable.This happened add webproject capability in your project.Then only you can deploy your project in server.(right click your project-> My eclipse->Add web service capability)

    Thanks,
    Mejat

  48. 48. suman on June 12th, 2009 5:30 pm

    Hi All,
    i have WTP plugins , and Flexbuilder how can i activate the wtb plugins Flex3.While creating the new project am not getting the combined flex and java project. can any one help regarding this.

    thanks
    suman

  49. 49. Maverick on June 17th, 2009 11:13 pm

    Thanks,
    You provided the additional clarification I needed when the wizard prompted me for the “flex war” file.

  50. 50. Mona on June 18th, 2009 10:03 pm

    Hello,

    Can somebody suggest how to add JBoss server to the target runtime?

    I am getting this error:
    Missing classpath entry \your_server_root\appservers\jboss\bin\run.jar

    Please suggest!

  51. 51. Anil on July 28th, 2009 11:28 am

    Hi,
    I am very new to Flex Builder and need to create J2EE project. I have already added WTP in Flex Builder 3, but still don’t see “Create combined Java/Flex project using WTP” coming for me. How can I run eclipse.exe with -clean as I don’t find “eclipse.exe” inside Adobe ?

    Thanks,
    Anil

  52. 52. Mihai Corlan on July 28th, 2009 3:57 pm

    @Anil

    Hi there, you should find the executable inside the Flex Builder installation folder. If you have the standalone version of Flex Builder, it might be named “FlexBuilder.exe”.

  53. 53. Christian on August 21st, 2009 6:11 pm

    Hello folks, well i am a little confused about the use of Flex and java, this is my problem: My java application must read two .zip files from an online server. These classes will load and parse the data in a Thread and perform certain actions depending on such info. The problem occurs when my flex application calls the java method that queries such data. I need to WAIT until the loading has finished. Any ideas?
    Another doubt is if the Java classes are being compiled and transformed into some form of ActionScript classes.
    Maybe I’m lost in space, so please I need a light in the darkness, thank you.

  54. 54. Mihai Corlan on August 23rd, 2009 1:50 pm

    @Christian

    The simplest solution, I think, is to use Data Messaging. Your Flex client is the consumer, and the java classes are the producer.

    Java classes are not compiled and transformed into ActionScript code.

  55. 55. DT on August 25th, 2009 7:24 am

    thanks for the tip. works great!

  56. 56. toswf on September 4th, 2009 10:47 am

    hello!
    we have finished as you said in the article,but we can not run on server.It simply said can not find the resource.the url is http://localhost:8400/WTP_test/WEB-INF/classes/WTP_test.mxml/

  57. 57. Mihai Corlan on September 4th, 2009 3:43 pm

    @toswf

    I think you made a mistake, because normally the URL should look like this: http://localhost:8400/WTP_test/WTP_test.html

  58. 58. @ndrio on September 21st, 2009 4:12 pm

    Thanks a lot for you very informative post. It helped me to set up my Flex/Java project with LiveCycle in 15 minutes.

    Keep up the good work!

  59. 59. Hemang on October 7th, 2009 12:49 am

    Hi,

    Is it possible to directly invoke a java class from flex application?

    Thanks.

  60. 60. Mihai Corlan on October 7th, 2009 12:52 am

    @Henmang

    If the class stays on the server, then yes. There are two server side frameworks from Adobe (BlazeDS -open source and LiveCycle Data Services -commercial product) that offer RMI style invocation of the exposed classes on the server from the Flex/AIR client. If you search on remoting Flex and Java you’ll find tones of articles explaining this topic

  61. 61. Flex and Java in Eclipse « Techie Note on October 9th, 2009 2:22 am

    [...] Flex and Java in Eclipse Posted on October 8, 2009 by mylblog http://corlan.org/2008/06/05/creating-a-combined-flexjava-project-in-flex-builder-wo-lcdsblazeds/ [...]

  62. 62. Rakesh on October 9th, 2009 9:41 pm

    Hi,

    Thanks for posting this nice tutorial but i have a question. I am trying to develop a flex application with java/j2ee. I was wondering how to communicate from one flex page to other using servlet as controller.
    I am trying to develop a small application like login,registration and search from database using Flex as front end and Java/J2ee as back end.

    I hope you would have got an idea i am trying to develop.
    Please help me in this regard.

    Thanks,
    Rakesh

  63. 63. Bill B on October 23rd, 2009 10:19 pm

    Thanks for helping me get the project setup with WTP. Can you shed some light on how to deploy a war file with everything packaged correctly via Eclipse? Is there a way to automate this process? When I do Export/ Select War
    /WAR Export/ Destination = tomcat/webapps/flex_project I get the following error:
    java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jst.j2ee.commonarchivecore.internal.CommonArchiveFactoryRegistry

    I guess I’m missing something in the initial server setup; I’m not clear on how and when the project, or which parts of it, are to be deployed.
    I’m using Adobe Flex Builder 3 on top of
    Eclipse Version: 3.4.2

    Thanks!

  64. 64. Santosh on October 29th, 2009 6:07 am

    Mihai,

    Great article but I am not able do this for Flash Builder 4 Beta 2. I don’t see Europa Discovery and see Ganymede Discovery instead. I couldn’t get far in the wizard as it kept telling me of incompatible configuration.

    Help please!

  65. 65. M Zach on November 30th, 2009 11:50 pm

    Hi Santosh,

    Europa is the older version auf eclipse 3.3

    Ganymede is the name of version 3.4

    see
    http://en.wikipedia.org/wiki/Eclipse_ide

    So take ganymede and it should work!

    By
    mz

  66. 66. sbliss on January 6th, 2010 12:36 am

    Mihai,

    I am also running Flash Builder 4 Beta 2 on Mac. I want to do combined Flex/Java development. I am supposed to install the Eclipse WTP plug-in to be able to do that. I went through the process you illustrated above for i.e. Help -> Software updates -> Find and install -> Select new features to install. i arrived at 2 options:

    1. Ganymede Discovery
    2. The Eclipse Project Updates

    Ganymede Discovery gives this error message:- “NAB/MWT for Linux GTK (0.9.9.200806181757) operating system does not match current environment.”

    The Eclipse Project Updates opens another field with several features under it but does not include WTP plug-in.

    i followed the link you provided to Eclipse.org site. Clicked on downloads and this is where I got even more confused. Nothing there made any sense because It was hard to determine one is which. Please help. Thanx in advance.

    sbliss

  67. 67. naveen on February 1st, 2010 11:04 am

    Hi Mihai Corlan,

    Thanks for your Tutorial, I have one question that while i am configuring target runtime in Flex Builder which is a eclipse plugin i am unable to see my Tomcat v6.0 which i have installed but i can see other earlier versions of Tomcat.What should be the problem.

    Regards,
    Naveen.

  68. 68. Katam on February 8th, 2010 4:06 am

    Hi Mihai Corlan,
    Thaks for the tutorial. It really helped alott..

    Regards,
    Katam

  69. 69. Online Sweepstakes on February 10th, 2010 11:00 am

    I admire what you have done here. Thank you for sharing. We will look forward for your future updates.

    Thanks

  70. 70. Anna on February 27th, 2010 12:34 am

    Hi
    I saw and have installed WTP. I am a novice in this, but i want to try my hand in flex as i have some spare time now. Can you tell me how to create a simple java/flex project using only WTP.
    Say, for populating a string in a textinput area from a javaclass.
    Can you send me or even upload a complete zip folder, so that I can get the directory structure and what goes in which folder and also how the class and mxml will get connect.. Please Someone help me. I have eclipse and flex 3 builder

  71. 71. Mihai Corlan on February 27th, 2010 1:08 am
  72. 72. siva on April 28th, 2010 8:56 am

    Hi,

    my projects environment is flex+java+blazeds+spring.
    I have flex builder 3 ide.

    Please tell me if the bove combination would work in flex builder 3 + WTP.

    I just want to make sure before i start development.

    Also Can you help with cvs configurartion in flex builder 3?

  73. 73. Mihai Corlan on April 28th, 2010 10:06 am

    @siva

    Yes, it should work. Regarding cvs and Flex Builder 3, you install a plugin that gives you support for cvs and you are good to go…

  74. 74. Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS « Techie Note on August 4th, 2010 9:12 pm

    [...] Creating a combined Flex/Java project in Flex Builder w/o LCDS/BlazeDS Posted on August 4, 2010 by mylblog http://corlan.org/2008/06/05/creating-a-combined-flexjava-project-in-flex-builder-wo-lcdsblazeds/ [...]

  75. 75. qding on August 27th, 2010 6:38 pm

    I followed the tutorial and got the error:
    “One of rmore constraints have not been satisfied”.

    I use
    “all-in-one” eclipse with wtp
    Flash builder plugin 4
    tomcat 6.0.29
    blazeds.war

    Page 1:
    1. project name and default project location;
    2. application type: web
    3. sdk version: default sdk (flex 4.1)
    4. server technology: j2ee, BlazeDS
    5. checked creating combined java/flex using wtp
    6. java source folder: src

    Page 2: j2ee settings:
    Target runtime: Apache Tomcat v6.0
    context root and content folder: take default
    blazeDS war: pointing to my downloaded blazeds.war
    out-put folder: bin-debug

    Page 3: Main source folder and Main application file: take default

    Output folder URL: http://localhost:8080/myproject/

    Errors are encountered while creating the project
    reason: One or more constraints have not been satisfied.

    Would you please point out what I missed or did wrong. Thank you.

Leave a Reply




Switch to our mobile site