aspose file tools
The moose likes EJB and other Java EE Technologies and the fly likes Problems using instance variables EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Problems using instance variables EJB" Watch "Problems using instance variables EJB" New topic

Problems using instance variables EJB

Yuri Morais

Joined: Jul 10, 2006
Posts: 8
How'd I maintain some instance variables in memory (without persist) in a way that all the clients can acess and modify them?
I tried to use Stateless bean, but they are pooled, and because of that the attributes of one instance would be different of another.
Stateful beans would be good, but my attributes have to be shared between clients.

Does anyone know a solution??
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31397

You could use a singleton - an object that only has one copy in a given JVM.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

In a given JVM is a pretty big caveat.

This is correct, but if you cluster your application, you're in trouble.

I've seen alot of well thought out applications that fail miserably when they get clustered.

Many applications use a centralized database. Think about the implications of clustering, and a centralized database is a good idea. That's how many servers implement HttpSessions.


-Cameron McKenzie
Yuri Morais

Joined: Jul 10, 2006
Posts: 8
That's a good solution, but I am using these data in memory in order to avoid the access to database, these data also include cache.
I agree. Here's the link:
subject: Problems using instance variables EJB