Categories:
/ (391)(rss)
   general (23)(rss)
      austin (4)(rss)
      random (5)(rss)
      scooter (4)(rss)
   tech (368)(rss)
      books (38)(rss)
      coding (10)(rss)
      java (160)(rss)
      jobs (8)(rss)
      mac (67)(rss)
      misc (55)(rss)
      net (16)(rss)
      ruby (4)(rss)
      xml (7)(rss)

JBoss:
A Developer's Notebook

JBoss: A Developer's Notebook

JBoss 4.0:
The Official Guide

JBoss 4.0 Guide

XDoclet in Action
cover

Recent Entries

Search entries

Referers Disabled(referer spam)

NetNewsWire blogroll

CapMac
blosxom

       

Fri, 08 Jul 2005

::Redeploy web apps without losing the HTTP session:: [/tech/java] (08:27)

The bug fix cycle on a web application can be time consuming. You've worked yourself into the application and found a bug. You fix it and redeploy. The redeploy should be fast, but it can take quite a few clicks to drill into an application far enough to get back to where you were because you usually lose your HTTP session when an application goes away. If your fix is pure JSP, sure you can overwrite your old JSPs and keep working, but fixes are often a bit more complex.

It's always bothered me, but I realized today that using JBossCache for HTTP session replication in JBoss solves this problem. If you run with session replication (add tc5-cluster-service.xml and mark your app as distributable) then your HTTP session is actually preserved on application redeploy even if you only have a single node. If you run into a logic problem, you just need to fix the code and redeploy the app then reload the page. You'll be right where you left off. Very cool.

There are some tricks here. In order to use HTTP session replication, everything that goes into the session needs to be serializable. (this shouldn't need to be true with TreeCacheAOP but with the standard TreeCache that is used now in JBossCache, that is true) This takes a bit of effort and can be a real headache if you haven't been careful about what goes into the session. It can also be a headache if you don't really take care of serialization details like SerialVersionUID. This bit me today when I changed a method on one of my JSF managed beans. JBossCache couldn't restore the session correctly because of the SerialVersionUID mismatch. Woops.

I feel dumb for not realizing this sooner, but I rarely develop an application with clustering on. However, it's so useful that I plan to develop all my applications as distributable, where possible, to take advantage of the longer lived sessions.

5 comments

writebacks...

wrote


Not sure what version of JBoss you're using but the default behavior of JBoss 3.2.7 will serialize your session to file during a redeploy. You don't need to setup clustering or anything.

coolhu wrote

coolhu
coolcoolhu coolhu

betcom wrote

Betcom
http://groups.msn.com/yahoo--personals/links.msnw http://groups.msn.com/betcom/links.msnw http://groups.msn.com/football-betting/links.msnw http://groups.msn.com/Gotomypc/links.msnw

football betting wrote

football betting
cool

sportsbooks wrote

sportsbooks
great

comment...

 
Name:
URL/Email: [http://... or mailto:you@wherever] (optional)
Title: (optional)
Comments:
Save my Name and URL/Email for next time