Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't stateful beans be exposed as webservices?

I have been reading about Stateful and Stateless session beans and came across a sentence that states that:

Stateful session beans cannot be exposed as web services.

Can anyone elaborate why ?


1 Answers

Every Stateful bean instance located in the EJB Container has an unique object identity.

From spec.: 3.4.7.1 Stateful Session Beans

A stateful session object has a unique identity that is assigned by the container at the time the object is created.

In order to use a Stateful bean, the client code needs to get a Stateful reference from the EJB Container. This reference has to be used to make every future request. Due to the reference object knows the identity associated to the stateful bean, you can be sure that all requests that participate in the "conversation" will be resolved for the same instance bean. This means that the Client has an important role in achieving the stateful behavior.

The SOAP protocol doesn't provide a way that allow to store in a web service client this identity, therefore, if the client doesn't know which stateful instance has the conversational state, every request will be processed by different ejb (such as the case of stateless).

like image 127
Gabriel Aramburu Avatar answered Jan 23 '26 19:01

Gabriel Aramburu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!