There is a deadlock between SFSB Synchronization lock and the Weld AbstractContext session context lock, which causes the SFSB and the session context to be locked until the SFSB lock timeouts with javax.ejb.ConcurrentAccessTimeoutException.
The situation can be caused by a producer inside a SFSB, such as:
@Stateful
@SessionScoped
public class StatefulProducer
{
@Inject
private Instance<OnDemandBean> onDemandBean;
@Produces
@SessionScoped
public Thing getThing() {
returnnew Thing();
}
public void demand() {
Thread.sleep(2000);
onDemandBean.get().foo();
}
}
@SessionScoped
public class OnDemandBean implements Serializable {
public void foo() {}
}
The problem occurs when there are two requests in the same session, with the first one calling StatefulProducer.demand and the other request injecting the Thing. The first request locks the SFSB synchronization lock first and then the Weld AbstractContext lock during the "onDemandBean.get()" call. The second request locks the Weld AbstractContext lock first and the SFSB synchronization lock next (during the producer getThing() call)