This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Stateless beans - still hazy about caching Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Stateless beans - still hazy about caching" Watch "Stateless beans - still hazy about caching" New topic
Author

Stateless beans - still hazy about caching

Billy Vandory
Ranch Hand

Joined: Mar 23, 2010
Posts: 57
I have a ServletContextListener where I do a lookup and store it in an attribute, as per below:




As I kind of understand it, the container has a Stateless bean pool. Would doing the above and using getAttribute to retrieve the bean in a servlet, say, still use the pool, or would it refer to the same bean instance? Or are caching local stateless beans even required? (ps: i know that this way isn't the best practice, I'm just trying to figure out the behaviour of caching stateless beans.)


Thank you very much,

Billy


Billy Vandory
Ranch Hand

Joined: Mar 23, 2010
Posts: 57
I did another test which has me a bit confused. When I call a method on a stateless bean where the method does not return for 10 seconds or so, all other methods on the bean are blocked. If I change the code to do a separate lookup for each method I want to invoke, the methods do not block, which leads me to believe that I should not cache the bean lookup ?


Gaurav Ag Agarwal
Greenhorn

Joined: Mar 24, 2010
Posts: 6
I saw what you did.. You can go from through this tutorial if you need it has all your basic details at http://www.roseindia.net/javabeans/javabeans.shtml


With Regards,
Gaurav Agarwal
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 8143
    
  52

Gaurav Ag Agarwal wrote:I saw what you did.. You can go from through this tutorial if you need it has all your basic details at http://www.roseindia.net/javabeans/javabeans.shtml


Out of curiosity, how is that "course" related to this specific question? A quick look at that page shows that it provides an overview of EJB applications, but is no way related to the specific question which Billy asked in this thread.


[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 8143
    
  52

Billy Vandory wrote:I did another test which has me a bit confused. When I call a method on a stateless bean where the method does not return for 10 seconds or so, all other methods on the bean are blocked.


Are you sure it's a stateless bean? And which application server is this?
Billy Vandory
Ranch Hand

Joined: Mar 23, 2010
Posts: 57
Jaikiran Pai wrote:
Billy Vandory wrote:I did another test which has me a bit confused. When I call a method on a stateless bean where the method does not return for 10 seconds or so, all other methods on the bean are blocked.


Are you sure it's a stateless bean? And which application server is this?


Yep, it's annotated as @Stateless

App server is Geronimo with an OpenEJB plugin.
Billy Vandory
Ranch Hand

Joined: Mar 23, 2010
Posts: 57
Jaikiran Pai wrote:
Gaurav Ag Agarwal wrote:I saw what you did.. --snip--



Last Summer?
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Stateless beans - still hazy about caching
 
Similar Threads
ejb lookups in spring config
@EJB
weblogic6.1 - JNDI name
Stateless and Stateful beans....
Injecting a Stateful Session Bean into a servlet