I just started to get my feet wet in developing a web application using jsf and seam and I wonder if there's a "nice" solution to my problem :-)
Setup: JBoss AS 4.2.2.GA Eclipse 18.104.22.168 Maven2 2.0.8 (also as Plugin in Eclipse) Multi module project using a war-ear structure
Goal: Webapplication using JSF, JBoss Seam, and Facelets on the view layer.
I have several years of experience in developing web applications using ColdFusion, PHP, HTML, and CSS and switched over to Java one year ago. Back in the days when I was working with scripting languages I was used to do the regular "CTRL-S + F5" cycle about 15 times a minute. So changing something in the code and seeing the result was mostly a matter of 4 seconds or so...
Now, working in Eclipse and having setup the whole Maven2 project structure the time between saving a change and actually seeing the result in an web browser has increased to about 1 minute (I work on an older Laptop). Everytime I even change the slightest bit in one of my css and xhtml files I have to rebuild the whole application and redeploy it into my JBoss server. I've been looking around for a way to reduce the redeployment time but couldn't find a satisfying solution.
Things I've tried so far:
Creating the html and css files without any app server and if everything looks fine merging that code into my project structure. This doesn't really work if I want to use any of the JSF-Taglibs out there.
Changing css (and xhtml) files directly in the tmp directory of my app server. In doing so I have to manually synchronize those files with my files in the project folders.
Using the tips that Adam Warski proposes on his blog at http://www.warski.org/blog/. Even though this looks promising I still have to include code and config files in my project which are completely irrelevant to the project itself and are purely for development purposes. And if I want to make a release I beforehand have to remove those helper configs from my code.
Yesterday I had a look at the JBoss Tools plugin set for Eclipse. I have to admit that I didn't completely understand what those plugins are actually doing but as far as I could see they're depending on some additional ant scripts in order to do somewhat of a hotdeployment which isn't quite fast either.
Now I'm asking myself if there's really not a better solution than the ones I tried or if I'm just doing something completely wrong..
I would be very glad for any hints, ideas or directions;-) Thank you for your time!
Okay, after doing some more digging in the dephts of the internet i found a solution to the problem stated above. I still don't know if I'm talking about things that are just too obvious to all experienced web application developers, but I thought that maybe somebody might be interested...
In short: I now deploy an exploded version of my war file directly into the JBoss deploy folder over Maven2. In doing so everytime I rebuild the war module of my project I get a fresh copy on the JBoss server directly. This cuts down the redeployment time to about 5 seconds, which is acceptable in my case.
How I do it: In order to not interfer with the general pom structure of my project I use maven profiles. I created a "dev" profile where I reconfigure the maven-war-plugin and disable the JUnit-Tests. So the real install or even release step will still be tested through JUnit tests. Here's how the important part of my pom.xml looks:
This setup gives me a pretty quick redeployment time. Since I'm using the maven plugin in eclipse it's quite easy to tell maven to use this profile over my IDE. The web application is instantly accessible over localhost:#port#/yourname after every mvn clean install command. If you're not using the eclipse plugin for maven you should also be able to tell maven to use the "dev" profile by using the -P option:
maven clean install -P dev
One thing I'm not a 100% sure about: If you want to also reload your class files in the war make sure you touch (open & save) your web.xml before you run maven. This should tell JBoss that something changed in the web app and that it should reload all the class files in your war. [ January 29, 2008: Message edited by: Lorenz Fischer ]