Originally Posted by
copeg
Depending upon the server environment, different class loaders or JVM's might load the classes - for read/write static variables this creates a problem as different instances of the variables might exist. There may be further problems with data synchronization, if multiple threads attempt to read/write at the same time.
Thanks for your feedback.
I also found this response from Mike Baranczak that makes the same point.
You should generally avoid static variables in Java EE or servlet containers, because the class loading can be a bit tricky - you may wind up with multiple copies when you don't expect it, or you may be sharing a single copy between different applications, or you may be keeping stuff in memory when you redeploy your application. You can make an exception in cases where the variable isn't exposed outside the class, and you don't really care how many copies of it you have (for example, logger objects).