-
Using static variables in stateless session beans(SSB) (2 messages)
- Posted by: aadil nisar
- Posted on: December 22 2007 11:02 EST
Hi, I have confusion over the behaviour of static variables in SSB.Actually i am facing a problem,in SSB a static integer variable(STIV) has been declared which is used to iterate String array(which conatains Names of the JMS queues to which messages are send.This caching of JMS queue names is done in other helper class ). Ocasionnally what is happening while iterating the Static String array(declared in helper class) using the static integer variable(STIV) declared in SSB i am getting arrayOutOfIndex array. This happens in one out 5000 transactions processed by the SSB The helper class is not synchronized The application used is Weblogic Please help me to clarify my dbouts abt the Static variable usage in SSBThreaded Messages (2)
- Re: Using static variables in stateless session beans(SSB) by Krishna Pothula on December 25 2007 01:53 EST
- Re: Using static variables in stateless session beans(SSB) by Gian G on March 28 2008 08:56 EDT
-
Re: Using static variables in stateless session beans(SSB)[ Go to top ]
- Posted by: Krishna Pothula
- Posted on: December 25 2007 01:53 EST
- in response to aadil nisar
hi, This is what I think... App server creates multiple EJB objects and stores them in a pool. When needed EJB is retrieved from the pool.. used.. and returned back to the pool. Similar to JDBC connection pool. Now it is totally upto the server implementation which decides when to flush the complete pool and re-create fresh objects. When flushing happens.. then all the objects are destroyed and your static variable gets re-initialized. Keeping a Static variable in a EJB is not at all a good idea. -
Re: Using static variables in stateless session beans(SSB)[ Go to top ]
- Posted by: Gian G
- Posted on: March 28 2008 08:56 EDT
- in response to Krishna Pothula
...
Agree: static objects are not permitted by the J2EE specification because you never know how many class loaders there are in your Web/EJB container. Therefore, the static object will be unique in the class loader only. If there are multiple class loaders, your static object will exist more than once (1 instance per class loader).
Keeping a Static variable in a EJB is not at all a good idea.