From a Java language perspective, nothing stops you from declaring a static variable in a session
bean class.It will compile as long as its syntactically correct.
From an EJB programming model perspective, the use of *non-final* static variables
is discouraged because it breaks the JVM-transparency that is an important aspect of the
EJB architecture.It should be possible to deploy a single EJB application to a cluster and
have it behave exactly as if it were deployed to only one server instance (albeit with higher
overall throughput/performance).Using non-final static variables breaks this property
because the bean instances in one JVM will see a different value for the static variable
than bean instances in a different JVM.
It also forces you to deal with synchronization
of the shared data, which is a complexity that was carefully avoided in the EJB programming
model by ensuring that each bean instance is single-threaded.
Bottom line is you can have "final static" data members in EJB classes but you should
avoid non-final (mutable) static data.
--ken