A J2EE Flex dev environment a ColdFusion guy can use!
Posted by Joe Rinehart at 8:35 AM
3 comments - Categories:
Joe Drinks Java | Flex
I've done a little bit of Flex work with Java RemoteObjects. I enjoyed the code side of it, which is where I was helping out, but the server deployment seemed very confusing and the development environment I encountered was painful, involving compiling a Java web app, deploying, compiling Flex app, running, debugging Java app via its logging, wash, rinse, and repeat. After talking to Chris Scott a bit over the weekend about his development environment, I decided to try to create a J2EE + Flex development environment that'd let me work the way I'm used to working with ColdFusion, involving:
- Code it -> Run it deployment (no manual compile / deploy)
- Interactive step-through debugging on both sides
- Easy creation / use of services through Spring-like factories
Many hours of reading / hacking / headaches later, I've got the following set up for my J2EE + Flex development stack:
- JBoss Application Server (JBoss AS) 4.2.2.GA
- Eclipse (Europa) and WTP plugins
- JBoss Tools
- Flex Builder 3 Beta 3 (in Eclipse)
- Maven (plus Maven Integration for Eclipse)
- Spring
- Debugging
If someone had told me setting up a J2EE server and getting it running was going to be the easiest part of this, I would have laughed. It was, though, and JBoss is one heck of a project. Unzip it, copy it where you want it, and do /jboss/bin/run.sh. Instant http://localhost:8080!
Need no introduction.
Eclipse plug-ins supporting JBoss AS, Hibernate, etc. I haven't used most of what it provides.
By configuring a JBoss server (basically, just telling it where I installed JBoss), I can then open a view called "JBoss Server View." Through it I can start/stop the server (like starting/stopping ColdFusion through Eclipse), and also force publication of my web app's code to JBoss in case the automatic publication / deployment gets behind.
By creating a Flex Project, using a J2EE server technology, and associating it with my JBoss 4.2 runtime, I automatically get a Flex + WTP project that contains both my Flex and Java code and deploys, war-style, as I update code.
Maven's almost like Ant on steroids, but it's a lot more than what Ant provides. The best part (that I've found so far) is dependency resolution. With Maven and its plug-in installed, I can right-click a Flex + WTP Project and choose "Maven -> Enable Dependency Management." Once that's done, I can right-click and do "Maven -> Add Dependencies." If I want to use Spring, I just search for "org.springframework," choose Spring, and it configures it and my classpath. Here's the kicker, though: Spring has dependencies that I don't even want to know about. Maven finds them and gets them, automatically! This'd be like right-clicking a ColdFusion project and being able to just say "Give me ColdSpring" and having ColdSpring downloaded and configured.
Note: you'll need check off "Maven Dependencies" in the J2EE Module Dependencies properties panel to get them to deploy to your project's WEB-INF/lib.
Not really part of the "development stack," but it's definitely part of my application stack. With the simple flex.samples.factories.SpringFactory added to my application, I can write Java classes (e.g., "ContactServiceImpl" in a bean with an id of "contactService") that know nothing about Flex (just like I would in ColdFusion), then make them available to Flex by simply adding this to my remoting-config.xml:
<destination id="contactService">
<properties>
<factory>spring</factory>
<!-- source = bean id -->
<source>contactService</source>
</properties>
</destination>
Last but not least, I can open my JBoss Servers view, right click my server, and choose "Debug" to start an interactive debugging session against deployed code. This lets me put breakpoints into the source code I'm editing in my IDE, just like I would in Flex and ColdFusion.
I can then put breaks in my Flex app, and launch a debuggin session on it as well.
Suddenly, I can step-through debug both the Flex and Java sides of the equation!
Conclusion
I've been involved with J2EE Flex development before, and I've gone running back to ColdFusion because of its perceived complexity.
Combining the right tools, though, is an investment well worth the time it takes to put them all together!
Brian LeGros wrote on 01/23/08 12:33 PM
Are you using Maven solely for dependency management or are you using it to build Java (.jar) and Flex (.swf, .swc) artifacts as well? Also, have you looked into using Maven with ColdFusion?On a side note, Apache has released Ivy (http://ant.apache.org/ivy/) which makes it extremely simple to add dependency management into your existing Ant scripts. I haven't had much luck using Maven with ColdFusion, so I think this is a great solution for that problem.