> Code snippetss
>
[quoted text clipped - 24 lines]
> Now as you can see SendOrder is not guaranteed to send Pen for the
> first Jsp and Car for th second Jsp. (EJB 2.1 FR specs Section 7.8)
No, I don't see that. If the OrderItem string were cached as an
instance variable then your statement would be correct, but for a local
variable it is not correct. Do note that caching the String in an
instance variable makes the bean stateful, but it is incumbent upon the
bean packager to declare it so in its deployment descriptor.
> I do not understand why. I looked in the net. When JSP 2 requires an
> instance why the container (EJB) is not saving the context fully
> (including OrderItem) of JSP A. If I push the OrderItem in the method
> it will save the context and this will work. I am not lookign for
> work-arounds but the reason for this specification.
You seem to have some misunderstandings. There is no context pushing
and popping involved in EJB. Stateless session beans are
context-independent -- that's what "stateless" means for them. Stateful
session beans are associated with one client at a time, and are only
assigned to a new client after any previous client releases them or
times out; managing conversational state is the responsibility of the
bean developer. Entity beans may be used simultaneously or serially by
multiple clients, in which case the results are governed by the exact
timing and sequence of events and the level of transaction isolation.
> JSP A or JSP B is not assured of sending the correct orderitem. It is
By which you mean that in your application it doesn't always happen?
> blamed upon the bean developer. The object's context (instead of
> method's cotnext) if I am saying this right needs to be restored by
> the container. Why this is not being specified ?
It very likely _is_ a problem with the bean implementation class or
deployment descriptor. The only thing I can suggest from what you have
presented is that the bean may be declared stateless in its deployment
descriptor but nevertheless exhibit stateful behavior. The solution in
that case would be either to make the bean truly stateless (often not
very difficult) or to declare it stateful.
> This is all happening in a stateless environment with in a call. I am
Define "stateless environment". What do you mean by that, and how are
you certain it is so?
> not leaving VOLUNTARILY (so that it becomes a requirement for
> statefulness between calls) but being pre-empted out by the
> OS/JVM/Container (in a stateless environment). So my call is in
> IN-FLIGHT.
Statefulness is not just about what happens between calls. If there is
any way for concurrent method invocations on the same bean instance to
interfere with each other then the bean is by definition stateful.
Please do also understand that it is possible for client code to
manipulate a bean instance in ways forbidden by EJB. One example would
be allowing multiple client threads to use a stateful session bean
instance concurrently. If the client violates the spec then the
behavior of the EJB is not defined.
John Bollinger
jobollin@indiana.edu