Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stateless Session Bean

 
murali kankanala
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I have implemented a Stateless Session Bean, part of the code snippet is below.



ejb-jar .xml



Client code:



My problem is when i call add() method on stateless session bean i trying to store the values in the global variables, so when i call different method on the same bean, the previous values which i stored in the session as global variables able to retain. How this is happening.? According the Stateless session bean behaviour it should not remember the values which i stored as part of my first call to my first method right?

Can you please clarify me ?

Appreciate your help.


Thanks,
Murali
 
Ninad Kulkarni
Ranch Hand
Posts: 802
Hibernate Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Murali,

You are using same calculatorRemote. Try using different instance of calculatorRemote and call appropriate method and post the result.
 
murali kankanala
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ninad,

I agree with this, if i close the existing bean and create new bean obviously its brand new bean eventually its not going to remember what previous state.

Lets say i have another stateful session bean. Suppose if i create first bean and called add() method and closed the bean. I have created new bean and called add() method, here you mean to say that this 2nd bean can remember that state of the previous bean.add().

I am worried how to see the difference between Stateless and Stateful practically.

Could you help me earliest.


Thanks,
Murali
 
murali kankanala
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried as you said,



I closed the first bean and created new one but the new bean is retaining the previous values of first bean.
Note: i am using same home refferencing.
 
Ninad Kulkarni
Ranch Hand
Posts: 802
Hibernate Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
murali kankanala wrote:I am worried how to see the difference between Stateless and Stateful practically
In lifecycle of satefull session bean ejbActivate() & ejbPassivate() methods come into picture but not in lifecycle of stateless session bean
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic