File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Stateless Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Stateless Session Bean " Watch "Stateless Session Bean " New topic
Author

Stateless Session Bean

murali kankanala
Ranch Hand

Joined: Nov 15, 2004
Posts: 110
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

Joined: Aug 31, 2007
Posts: 787

Hi Murali,

You are using same calculatorRemote. Try using different instance of calculatorRemote and call appropriate method and post the result.


SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
murali kankanala
Ranch Hand

Joined: Nov 15, 2004
Posts: 110
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

Joined: Nov 15, 2004
Posts: 110
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

Joined: Aug 31, 2007
Posts: 787

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
 
Consider Paul's rocket mass heater.
 
subject: Stateless Session Bean