• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

Stateless Session Bean

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 814
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 814
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Slime does not pay. Always keep your tiny ad dry.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic