Announcement Announcement Module
No announcement yet.
The poor state of (Spring) web app development Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • The poor state of (Spring) web app development

    There is a lot of buzz about Rails, a simple web app framework for Ruby. Rails runs in the classic (pre-spawned) CGI setup; it does not run inside a container but in a web server process.

    Anyway, Rails is very simplistic (yet very effective for people) and I don't want to start a flameware by comparing it to Spring.

    The one thing that I do want to start a discussion about is web app development. What I really liked about Rails is that you can edit basically everything live without redeploying your application every time. It is something I would really like to see in Java. Or at least, a better version of what we have now.

    With Rails you can add new controllers and models (their imlementation of the Active Record pattern) live. You don't have to restart your web app. Change a few lines of code and they will be picked up immediately. Same with 'rhtml' templates.

    Compare this to the edit -> build -> package -> redeploy -> test cycle that we now use in Java.

    Wouldn't it be great if there was a standard setup where you could:
    • Edit JSP or other templates live
      Create Spring beans and plug them in live
      Create new controllers live
      Change your *-servlet.xml bean descriptors live
      Reload code in DAO and Application Logic object live

    Most IDEs already compile and check your code realtime, so why can't they make they make that code available to the spring container immediately. Or with a simple 'publish' or 'synchronize' button when you think you are done with a set of changes.

    Anyone interested in a Spring/IDE/ServletContainer integration that tries to do things like this? I think it would be really cool to kick off a discussion here to see what things are possible and maybe try to implement some.


  • #2
    Some app servers support a type of deployment that is 'live'. Change a resource and it gets redeployed.

    To remove the compile step one would have to move more toward scripting languages for the JVM. There is a JSR that addresses this.


    • #3
      Some of this is already available

      I haven't used Ruby or Rails, so I can't comment on what it can do for speeding up the development cycle.

      What I can say is that with Spring and Java is that this is more of a function of the servlet conainter/app server than any particular framework that's in use. Although I suppose there's no reason some of this couldn't be pushed to the framework level, it just typically isn't.

      With most servlet containers and IDE's there are ways to decrease the pain.

      First, almost all servlet containers will let you deploy "exploded" during development. This means the files aren't in a .WAR or .EAR, they are just in the filesystem. This saves building the .WAR. Typically, also implemented alongside that is a way to detect changes and reload part of the app dynamically.

      For example, my current develpoment setup has tomcat pointing at my eclipse workspace. Eclipse is set to compile the classes automatically on changing into WEB-INF/classes. My application is also set to "reloadable" in the definition for it in tomcat. So whenever I change any class in the application, it automatically reloads the app.

      Now, because this happens at the classloader layer with Tomcat, the whole app is reloaded. Which, since I have a bunch of spring/hibernate stuff, takes longer than I'd like but it's not bad.

      For the view, I'm using velocity, so changes are always picked up automatically (I haven't turned on any caching yet, but if I did I would disable it for most development). If you are using JSP's, most servlet containers will automatically detect changes and recompile/reload the individual generated servlet, as long as you have deployed exploded.

      So my workflow is edit->wait 30 seconds for the app reload->test. Other containers may have fancier reloading abilities that can avoid the 30 second restart wait. I think it might be possible to use remote debugging to swap individual classes on the fly with tomcat, but I haven't tried it yet.

      That's kind of the 80% solution. I suppose spring directly supporting dynamic swapping of views and controllers might be possible if it wanted to implement its own classloader? That might be interesting because I've had a thought that I would want to use spring to re-wire implementation classes on the fly....


      • #4
        I agree with rob_from_ca. We use Jetty and an Eclipse plugin. Works like a treat. We use FreeMarker so there's no JSPs to recompile. Indeed we can change message bundles as well without restarting the container. If you need a container running, it's typically to fine-tune these sort of reloadable files. If you need to change a Java class etc, waiting the 15 seconds for the container to reload isn't such a big problem, especially given it's reasonably infrequent in the daily development cycle.


        • #5
          I might be talking out of my **** but I have a feeling I read somewhere Webwork (don't remember which version) supports scripted actions, using Rhino(?).


          • #6
            More of a question of the state of IDEs for J2EE

            I hear you - I don't like the old "edit -> build -> deploy -> test" process of local development either.

            But a lot of IDEs available today cut out the middle-man and offer various types of hot method replacement and hot deployment so that you effectively get into an "edit->test" iterative development cycle.

            I'm a contractor and as fate would have it have been working in IBM shops for some time so I have been developing w/ WSAD (and previously VAJ) which have offered integrated hot deploy for some time.

            Once you get use to that it's hard to switch back to the old Ant script build -> restart server way of life.

            WSAD is more or less being offered for free now through the Ecplise "Server Tools" project. Check it out sometime.

            Cheers, Greg


            • #7
              keep in mind that there is no part of a spring app that can not be tested in JUnit. Build your app to JUnit tests, then all you have to deal with is some integration testing. If you are using JSP as your view, the MyEclipseIde Plugin for Eclipse allows your modify your JSP's, CSS, etc. without having to redeploy the app.