Friday, May 06, 2005

Velocity, Struts and Tomcat Clusters

I just recently found my self using Tomcat with Velocity and Struts
And as would be expected I needed to use more than one Tomcat server for load balancing and Reliability so I looked into how to Cluster Tomcat.

There are 3 options with tomcat 5.0

  1. Save your session to a file
  2. Save your session to a database
  3. Use Tomcats multicast Replication
I played with #2 and #3 and found out that Velocity puts a Object into the session object that is used to synchronize on.

It creates a empty Object and put it into the Session then when doing any actions it uses the Object as a mutex so that only thread can act on any session. This sounds smart? Right?

Well when I tried to serialize the session I ran into many problems because Object is not serializeable.

I was banging my head against the table over and over trying to figure out why I was getting session.mutex is not serializeable.

Then I had to try and find where session.mutexwas getting put into the session because I knew that I was not doing it

Finally I found out that it was Velocity Tools that was putting an object into the session.

So I the solution was to recompile velocity tools so I could extend it and I do a synchronize on the session itself. Now there are no extra object to passed to the other clusters.

Technorati Tags: , ,

2 Comments:

At 8:49 AM, Blogger Billy said...

Hey, you have a great blog here! I'm definitely going to bookmark you!
I have a Consolidation debt site/blog. It pretty much covers Consolidation debt related stuff.

Come and check it out if you get time :-)

 
At 2:21 PM, Blogger nathan said...

noticed this blog entry the other day. i thought you should know, it's not 100% safe to synchronize on the session object as Tomcat will quite frequently return a new object as the session. that's why we do the object lock thing.

i'll see about making that object serializable in the next release.

 

Post a Comment

<< Home