make change from session-type as stateless to statefulsessionbean


in our application statelessbeans were written;

in the ejb-jar.xml if i make change from session-type as stateless to statefulsessionbean;

what problems will i get from the application?

LVL 20
chaitu chaituAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you will not get any problem, but u do this to create a state of ur EJB, which means that their is Serializable member fields in ur EJB that u want to maintain their state, also the Client using the beans will handle them differently, in order of the client to stay connected to the EJB state, they must keep the local or remote reference alife until unneeded, and when it is no more needed u must call remote.remove() ( or local.remove() ) or the bean will be passivated (the state is stored on App. Server storage) or in memory for ever
chaitu chaituAuthor Commented:
i didnt understand much can u explain more in detail;
As he said u wont get any problem..
only thro ejb-jar.xml the container will know whether it is statefull or stateless.
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Also u  can put code in ejbActivate() or ejbPasivate(),regardless of whether the ben is stateless or statefl,even though it will never be called it the bean is stateless.
Think about it ,Look at the sessionBean interface notice that there is not a StatelessSeesion Bean and StatefulSeesionBean interface ,there is just a SessionBean and both stateless and stateful session bean implement it .so,there is nothing in ur class that specifically says ur bean is stateless,its only deploy time,when you tell the deployment desciptor(ejb-jar.xml) tht the bean is stateless or stateful,that it actually matters.
Infact ,you could write a bean that has a no-arg create,and keeps no client state,and you can deploy it with either setting -stateless or stateful- and it will work,as long as you've taken care of passivation and activation.
chaitu chaituAuthor Commented:
----"Think about it ,Look at the sessionBean interface notice that there is not a StatelessSeesion Bean and StatefulSeesionBean interface"

in entity bean interface also that there is not a BMP and CMP

But there was certain difference between them;

in BMP we will implement the methods where as CMP container will do that.

but in the case of stateful client state will be maintained  and in stateless there is no state maintained and no there is no activation and passivation;

How these scenarios(activation and passivation) will be helpful for stateful sessionbean.
in case on stateful, activation and passivation is useful to open/close connections like database connections or conections to Legacy systems or maybe connection to Backend like calendar or email
a good example of a stafeful session bean is for example a shopping cart bean, user keep navigating throught the site and add items to shopping cart hence it is stateful operation, but in usually in case like this Servlet sessions is more popular to use.

returning to activation and passivation u may do domething like this:

public void activate()
Connection conn = getConnection();

public void passivate()
 conn = null;


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.