Skip to main content

Problem:

  • Product Name: Borland Enterprise Server, AppServer Edition
  • Product Version: 6.0 and above
  • Product Component: EJB Container
  • Platform/OS Version: all supported
  • JDK/Compiler Version: all supported

How to resolve "Failure in Synchronization Callback" exception

Following exception stack trace is encountered when using Stateful Session bean (SFSB):

2008-06-16 00:04:56,011 ERROR - Failure in synchronization callback org.omg.CORBA.NO_PERMISSION: Attempting to call non-reentrant bean multiple times: public abstract voidjavax.ejb.SessionSynchronization.afterCompletion(boolean) throwsjavax.ejb.EJBException,java.rmi.RemoteException vmcid: 0xcafeb000 minor code:2750 completed: Maybeat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.inprise.vbroker.rmi.CORBA.UtilImpl.newInstance(UtilImpl.java:125)
at com.inprise.vbroker.rmi.CORBA.UtilImpl.mapRmiException(UtilImpl.java:269)
at com.inprise.ejb.Util.convert(Util.java:62)
at com.inprise.ejb.Dispatcher$3.invoke(Dispatcher.java:975)
atcom.inprise.ejb.SynchronizationPool$Synchronization.doCallback(SynchronizationPool.java:213)
at com.inprise.ejb.SynchronizationPool$Synchronization.after_completion(SynchronizationPool.java:310)
atorg.omg.CosTransactions.SynchronizationPOA._invoke(SynchronizationPOA.java:67)
atorg.omg.CosTransactions.SynchronizationPOA._invoke(SynchronizationPOA.java:43)
at com.inprise.vbroker.poa.POAImpl.invoke(POAImpl.java:2918)
at com.inprise.vbroker.poa.ActivationRecord.invoke(ActivationRecord.java:187)
atcom.inprise.vbroker.poa.ServerInterceptorManager$ARWrapper.invoke(ServerInterceptorManager.java:115)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.doRequest(GiopProtocolAdapter.java:862)
atcom.inprise.vbroker.IIOP.ServerProtocolAdapter.doRequest(ServerProtocolAdapter.java:68)
atcom.inprise.vbroker.GIOP.GiopProtocolAdapter.dispatchMessage(GiopProtocolAdapter.java:1163)
at com.inprise.vbroker.orb.TPDispatcherImpl$TPDispatcher.run(TPDispatcherImpl.java:110)
at com.inprise.vbroker.orb.ThreadPool$PoolWorker.run(ThreadPool.java:94)

Resolution:

The issue occurs when SFSB call the re-entrant bean in a transaction. For example:

SFSB A --> SFSB B --> SFSB A

In pdf page 76 of the EJBspec 2.0, it states the following


Clients are not allowed to make concurrent calls to a stateful session object. If a client-invoked business method is in progress on an instance when another client-invoked call, from the same or different client, arrives at the same instance of a stateful session bean class, the container may throw the java.rmi.RemoteException to the second client[4], if the client is a remote client, or the javax.ejb.EJBException, if the client is a local client. This restriction does not apply to a stateless session bean because the container routes each request to a different instance of the session bean class.

If you look at the sequence diagram in the attached file and the exception stack trace, you can see the transaction is already committed. If the client has implemented the afterCompletion method of the SessionSynchronization interface, it will not be executed when this exception occurs.

There are 2 ways to resolve this issue.

  • Ensure the code invocation path does not callback to itself in a transaction
  • Use stateless session bean instead of stateful session bean

    Alternatively, the stateful session bean can provide an empty implementation for the afterCompletion method of the SessionSynchronization interface. It will not prevent the exception from occurring but it will ensure there is no impact to the application.

    Author: Matthew Ong

    Related documents:
    • stateful-transaction-seq.zip

Old KB# 15627

#StatefulSessionBean
#BorlandApplicationSerrver
#VisiBroker
#Security