InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Java Web Frameworks Increase Support for Auto-Reload

Posted by Geoffrey Wiseman on Apr 25, 2007

Sections
Development
Topics
Java ,
Web Frameworks
Tags
Spring IDE ,
Grails ,
JBoss Seam ,
Struts ,
Spring ,
Spring Web Flow ,
Tapestry

In building software, the speed of the compile-build-test cycle has a significant impact on the productivity of the developer. If a developer must recompile and rebuild the application, redeploy it, and potentially restart the server, this takes time that can slow down the development process.

Some platforms for building web applications, particularly those using dynamic and scripting languages, allow developers to make modifications to the application (code, templates and configuration) and see the results of those changes immediately.

This feature is called different things, such as auto-reload and incremental hot-deployment, and the extent to which platforms and frameworks support something of this nature has an impact on how rapidly developers can develop and maintain a web application.

Auto-Reload in Java

Most Java web frameworks have had some level of support for an auto-reload capability, often starting at the level of a page templating language. For instance, it has long been possible to modify a JSP file within a web application and have the application server detect the change and restart.

As web applications grow in size, the time required to restart the server often increases, and this form of auto-reload may require too much time and have too many limitations, particularly when compared to the competition, such as Ruby on Rails.

With several Java web frameworks having recently announced increased support for auto-reload, InfoQ took the opportunity to catch up with some of the more popular Java web frameworks and compile the results.

Grails
Grails supports auto-reloading with some limintations:

All Grails artifacts (controllers, tag libs, services etc.) are reloadable in Grails, however there are some quirks:
  • Services can currently only be reloaded if the 'transactional' property is set to false
  • Domain Classes are re-mapped to the database at runtime. If the data source is configured to auto-generate the database via the 'update' setting of the 'dbCreate' property it will do its best effort to update the database. This process doesn't always go smoothly however and changing domain classes occasionally require an application restart

Seam
Seam 1.2.1 has just introduced what they're calling "incremental hot-deployment":

Only Seam JavaBean components are supported - it doesn't work for entities, and it doesn't (yet) work for EJB3 components. We do plan to support this feature for EJB3 components, but it looks like we won't have time to work on that until after JavaOne.

Spring MVC & Web Flow
Spring 2.0.4 allows a Spring MVC dispatcher to be reloaded. Spring's support for dynamic languages allows controllers and validators to be written in Beanshell and Groovy, and refreshed without restarting the application.

Spring Web Flow, which can be used with Spring MVC, Struts 1 and 2 and JSF, can be used to take responsibility for the navigation and state management of a web application, allowing the flow to be rebuilt without restarting the server.

Keith Donald adds this, about Spring IDE 2.0's support for Spring Web Flow:

You can now use Spring IDE 2.0 to make a change to your navigation logic graphically (by drag-n- drop) and just see those changes take affect, again with no container restart. You don't even have to save your flow definition (the tool does it for you).

Struts 2
Struts 2 allows actions to be reloaded if they have changed. Patrick Lightbody cautions:

Ultimately the problem is that the chain of objects (ie: stateful action -> stateless spring services) gets so complicated that it becomes difficult to know what can successfully reload and what can't.

Tapestry 5
Although Tapestry 4 supported reloading of the HTML templates and page properties in a development mode, Tapestry 5 is adding extensive support for live class and template reloading.

As with the other frameworks, there are limitations:

  • Auto-reload is not currently supported for resources in JAR files.
  • Since the reloading uses classloaders, this can result in ClassCastExceptions when communicating with classes that haven't been reloaded.
  • The potential for memory leaks if you retain references to classes that have been reloaded.

11 comments

Watch Thread Reply

RIFE by Geert Bevin Posted
Re: RIFE by Geoffrey Wiseman Posted
Re: RIFE by Eelco Hillenius Posted
Wicket supports it as well by Eelco Hillenius Posted
Grails by Kong Fanbin Posted
Impact by Kit Davies Posted
Re: Impact by Jesse Kuhnert Posted
Re: Impact by Geoffrey Wiseman Posted
like Jetty, but better by Thom Nichols Posted
Slowing down the development process??! by Alexander Snaps Posted
Reloading+exploded directory by Chetan Mehrotra Posted
  1. Back to top

    RIFE

    by Geert Bevin

    Hmm, well RIFE has been doing auto-reload, auto-compile and auto-reconfig since day one, ie. 6 years already.

  2. Back to top

    Wicket supports it as well

    by Eelco Hillenius

    Wicket supports auto reloading through a special filter (ReloadingWicketFilter). Limitations are stated in the JavaDocs.

  3. Back to top

    Grails

    by Kong Fanbin

    Grails supports this feature, and I found it is very useful for developer

  4. Back to top

    Impact

    by Kit Davies

    How great really is the impact of not having auto-reloading? I suspect it is more about the interruption to the thought flow than the actual time involved. IME, the impact is proportional to the number of steps required to redeploy. Hence auto-reload has zero impact but (as the examples above illustrate) not all frameworks support it, some only partially and all no doubt are more complex as a result. The alternative is to use a tool like Ant or Maven. Here the impact is restricted to a single step of invoking a target via a script or IDE plugin. Is this really too much?

    Kit

  5. Back to top

    Re: Impact

    by Jesse Kuhnert

    I think one of the reasons why autoreload of the application is not always ideal is because you are re-starting your entire application. This can vary between taking a few seconds and sometimes up to a couple minutes depending on how large your application is and the physical limitations of the computer you are doing this on... Ie it's dead / static software. Not very compelling for people in the dynamic language camp.

  6. Back to top

    Re: Impact

    by Geoffrey Wiseman

    Exactly -- on one of the applications I work on, the application startup takes over 30 seconds, so when you need to make a series of minor changes, this can be a very frustrating thing, waiting for the server to come back up just to check the change you made.

    Now, finding ways to reduce that startup time is certainly an avenue for discussion, but in the meantime, it makes any reload capabilities somewhat appealing.

  7. Back to top

    like Jetty, but better

    by Thom Nichols

    This is why I used Jetty when I did JSP development -- Eclipse's incremental compile + Jetty's auto-reload of JSPs meant that most stateless code would be auto-reloaded.

    Grails takes it one step further with Groovy's dynamic classloading by being able to reload Spring-loaded beans and domain classes that typically would require a server restart. Top notch productivity for me.

  8. Back to top

    Slowing down the development process??!

    by Alexander Snaps

    I have come to notice something else than redeploys "just" slowing down the development process, which is far more armful: it doesn't promote agile development in the sense where, especially junior developers, tend to test less often. Of course we all have our code base covered at 99% by thoughtful tests, so this is almost no problem for most of us! The others can keep on reading ;)
    But the result I have observed is that developers tend to implement too much before redeploying, then all a sudden the application doesn't behave as expected and they switch to the debugger. And there is were most of their time gets waisted...
    So since Debugging sucks, Testing rocks, maybe Redeploys sucks as much and auto-reloads rocks even more for teams with junior members on board!

  9. Back to top

    Re: RIFE

    by Geoffrey Wiseman

    Thanks by the way, for the comments from RIFE, Wicket. While I hope you can all understand the challenge of trying to cover all Java web frameworks, I'm more than happy for the readers to get the information about the frameworks in which they are interested.

  10. Back to top

    Reloading+exploded directory

    by Chetan Mehrotra

    Reloading of configuration files is a necessary feature. In our application we were using Struts+Spring+Hibernate. So if any minor change is done in files required by these frameworks then one has to wait for a minute to get the app running again.
    This breaks the developer focus and they try to defer restarting till they have made any major change. We came up with a custom jsp which would load configuration files for specific framework and let the developer continue the work without restarting (in few case restart were required).
    And more the developer tries to defer restarting more are the chances of configuration error creeping in. So if reloading is provided as a inbuilt support in the framework that would be great.
    One more thing to make use of is the exploded directory mode of deployment provided by most app/web servers. I have seen teams using the process of making an ear/war in there devlopemnt process also. If they take advantage of exploded directory way of deployment then it would greatly reduce the time taken for restarting+deployment

  11. Back to top

    Re: RIFE

    by Eelco Hillenius

    Thanks by the way, for the comments from RIFE, Wicket. While I hope you can all understand the challenge of trying to cover all Java web frameworks, I'm more than happy for the readers to get the information about the frameworks in which they are interested.


    Sure. There's quite a few out there :)

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.