I think you can use JNDI and your ejb context to store such things provided
that they are serializable.  I don't think such a JNDI scheme would garantee
synchronization on your shared object.  I've also had difficulty makeing such
objects serializable but mine had socket connections buried in it, (connection
pool).   There is also the issue of performance and jndi lookups...
I eventually resorted to deploying all my global scope shared objects in  a
separate jar which is deployed on the server, not the ejb app, ie. I put it in
/orion/lib/thing.jar.  Make sure that any references to such objects are
nulled before passivation or the ejb's won't serialize cleanly...
Note also that this scheme will allow you to have a "server" scoped object.
If your using clusters, the that's a whole other kettle of fish...
wcn

Mikael St�ldal wrote:

> How do I store application scoped data in the EJB tier? Like using
> setAttribute()/getAttribute() in ServletContext ("application" in JSP) in
> the web tier.
>
> Using instance attributes in Stateless Session Beans doesn't work, since
> there can be several instances, and you never know which one is used. Using
> static attributes in an EJB class doesn't work well either, since they may
> be shared among several applications running in the same server.
>
> Is it possible to use JNDI for this? Can I just use rebind() and lookup()
> with arbitrary objects on the EJB JNDI InitialContext, just like I use
> ServletContext?


Reply via email to