In a J2EE environment, using static variables can cause thread synchronization troubles. The reason for that is that J2EE server can create multiple instances of your EJB's to handle multiple clients concurrently, as result of that static variables can be accessed by multiple threads concurrently.
Without synchronization (EJB business methods are not allowed to block on synchronized resources), corruption (dirty read/dirty write) could occur.

Using static variables is fine :
1. If they are final.
2. If they are initialized in a static block and not altered during the total lifetime of the variable.

Another aspect to consider is that J2EE containers can be designed to run in clusters as well, if a static variable is used in a clustered environment then it will break the cluster, i:e;
if you application is spread it across several machines in different clusters, then each part of the cluster will run in its own JVM.
Example - A method on the EJB is invoked on cluster 1 (we will have two clusters - 1 and 2) that causes value of the static variable (initialized at 20) to be increased to 21 from 20.
On the subsequent call to the same EJB from the same client, a cluster 2 may be invoked to handle the request. A value of the static variable in cluster 2 is still 20 because it was not increased yet and that means your application data is inconsistent. Therefore, it is vital that if static variables have to be used in a clustered environment then they should be made final. Del.icio.us Digg! My StumbleUpon Page