I have a Flex/Java web application that uses Maven as a build tool. Currently, if I want to debug the entire application I use Maven to create the WAR file and use the cargo plugin to deploy the WAR file and start up the app server. I then launch an Eclipse (with Flash Builder 4) Flex "Web Application" debug configuration and start debugging.
It all works very well, but I a开发者_C百科m looking for a way to make this faster. I'd like to be able to edit my Flex code and immediately launch my Flash Builder debug configuration without going through Maven.
Currently the output folder for my Flex client module is just the "bin" folder of the project. In a perfect world, I'd configure Flash Builder to put it's newly minted SWF file (and assets) directly into the app server I am running. Assuming this is impossible with remote app servers, and also impossible with the local app servers I run from Cargo, perhaps I can use another approach to running a local app server from Eclipse?
I don't know enough about Eclipse or Flash Builder to know what to do...HELP!
We are using Flash Builder but this should work for the eclipse plugin too. In the Flex Build Path configuration for the project set the output folder to the target folder where you have your web server pick up the SWF you are building. Set the Output folder URL to point to the context that launches the SWF and you should be good to go. Example:
Output folder: c:\java\tomcat\webapps\myapp
Output folder URL: http://localhost:8080/myapp
As an aside we have also found that using IE to test in makes things simpler as it tends to have less funnies with cached SWFs then Firefox or Chrome.
I'm using FlashBuilder with the WTP plugin..I'm using the same environment for both Flex and Java. As an application server I'm using Tomcat for the moment, and I configured the output folder like that:
${DOCUMENTS}.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\myproject
Where DOCUMENTS is a linked variable and represents the full path to my workspace: C:\projects\workspace-mypetprojects
Everything goes well, I do not have to restart the server or to build a new war when modifying the flex files.
First of all you should download Eclipse for Java EE developers* and install Flash Builder as a plugin, pointing to your existing Eclipse, during installation. Having that you should be able to create Flex project through
File -> New -> Other -> Flex Builder -> Flex Project
Here you need to set Application server type
to J2EE and make sure you have Create combined Java/Flex...
option checked. I usually leave Use remote object access service
option unchecked as I'm using GraniteDS so it's up to you if you need it or not.
On the next screen you need to configure your Application Server. Here are the steps for Tomcat:
Target runtime -> New -> Apache -> <<your preferable Tomcat version>>
(change server name and host name to whatever suits you best or - my favorite :) - leave it as it is)- Tomcat installation directory should point to where you've installed your Tomcat - by default it is
C:\Program Files\Apache Software Foundation\Tomcat 6.0
. If you don't have Tomcat installed you can do so by usingDownload and install
wizard - On the next screen you're supposed to add web applications you want to have deployed to the server but, as you probably don't have any right now, just press
Finish
. - Select Tomcat server you've just created (you may want to play with rest of the settings like Context root etc.)
- Next screen and some more settings I usually left default :)
- Finish
Window -> Show view -> Other -> Server -> Servers -> OK
will open servers view where you can manage your Tomcat server. Use RMB on your server name, then Add and remove
, select your application, click Add
and Finish
.
Now, 3 icons above the server name and to the right are used to start the server, starting from the left, in debug, normal and profiling mode. Press debug one and server should start - now you will be able to debug Java code you put on the server.
Last step is to start Flex app in debug mode. Below menu bar you can see icons similar to those used to start the server. Press the down arrow located near debug one and select Debug configurations
. Double-click Flex Application
, change the name of your newly created configuration and correct debug URL to match your server configuration (leave it as it is if you left everything default up to now). Press Apply
and Debug
and here you are debugging :) Use F5 to step into, F6 to step over and F8 to continue.
PS: You may want to change default browser your application is started in (by default it is in-built Eclipse browser I think). You do that by going to Window -> Preferences -> General -> Web Browser
.
Happy debugging :)
* unfortunatelly I'm using older version of the IDE so above steps may be slightly different than what you have in your Eclipse but you should get general idea. Also Flex Builder 3 seems to be incompatible with latest Eclipse releases (Flex Projects are not fond of being created in Helios release)
精彩评论