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
- Save your session to a file
- Save your session to a database
- Use Tomcats multicast Replication
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 itFinally 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.
