The container serializes calls to each stateful and stateless session bean instance. Most containers will support many instances of a session bean executing concurrently; however, each instance sees only a serialized sequence of method calls. Therefore, a stateful or stateless session bean does not have to be coded as reentrant.
SCJP 5.0 94%
OCE-EJBD 90%
Does this mean , below should not work in any app-server (its applicable to stateful as well) ?
SCJP 5.0 94%
OCE-EJBD 90%
4.10.13 Non-reentrant Instances
The container must ensure that only one thread can be executing a stateless or stateful session bean instance at any time. Therefore, stateful and stateless session beans do not have to be coded as reentrant. One implication of this rule is that an application cannot make loopback calls to a stateless or stateful session bean instance.
The getBusinessObject(Class businessInterface)method returns a business object reference to the session bean’s business interface or no-interface view. In the case of the no-interface view, the argument is of the type of the bean class. Only session beans with an EJB 3.x business interface or no-interface view are permitted to call this method.
If a subsequent invocation were made on the result of getBusinessObject, then:
- For a stateless session bean, the invocation would be delivered to another stateless session bean instance.
- For a stateful session bean or singleton session bean, the invocation would be delivered to the bean instance that returned the reference. The existing rules regarding reentrancy would then apply.
The object reference returned from SessionContext.getBusinessObject is to be used for the subsequent invocations (see 4.3.3), not reentrant calls.
4.10.13 Non-reentrant Instances
The container must ensure that only one thread can be executing a stateless or stateful session bean instance at any time. Therefore, stateful and stateless session beans do not have to be coded as reentrant. One implication of this rule is that an application cannot make loopback calls to a stateless or stateful session bean instance.
This last explanation ("The existing....") is being discussed to be changed right now:
The object reference returned from SessionContext.getBusinessObject is to be used for the subsequent invocations (see 4.3.3), not reentrant calls.
SCJP 5.0 94%
OCE-EJBD 90%
I am not sure if these questions make sense but seems that I am missing something here.
When a loopback call is a made , there is still a single thread of control (be it on same stateful session instance or new stateless instance), then why the reasoning for stopping the re-entering in the bean is given in terms of thread ?
What do you mean by subsequent invocations over here ?
That also implies to me getBusinessObject will only be useful in case of singleton session beans.
SCJP 5.0 94%
OCE-EJBD 90%
stateful and stateless session beans do not have to be coded as reentrant.
SCJP 5.0 94%
OCE-EJBD 90%
aused by: javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=com.ivan.scbcd6.client.StatefulSessionBeanSessionListener/bean,Remote 3.x interface =com.ivan.scbcd6.StatefulSession3Remote resolved to intra-app EJB StatefulSession3Bean in module MyStatefulSessionBeanEJB.jar,ejb-link=MyStatefulSessionBeanEJB.jar#StatefulSession3Bean,lookup=,mappedName=,jndi-name=java:global/MyStatefulSessionBeanEJBEAR/MyStatefulSessionBeanEJB/StatefulSession3Bean,refType=Session' . Actual (possibly internal) Remote JNDI name used for lookup is 'java:global/MyStatefulSessionBeanEJBEAR/MyStatefulSessionBeanEJB/StatefulSession3Bean!com.ivan.scbcd6.StatefulSession3Remote' [Root exception is javax.naming.NamingException: Lookup failed for 'java:global/MyStatefulSessionBeanEJBEAR/MyStatefulSessionBeanEJB/StatefulSession3Bean!com.ivan.scbcd6.StatefulSession3Remote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.ivan.scbcd6.StatefulSession3Remote [Root ....