Program: 28813
Project: 28813
Buggy source:
/** 
 * Actual message delivery happens in three steps : 1) beforeMessageDelivery(Message, MessageListener) This is our chance to make the message delivery itself part of the instance's global transaction. 2) onMessage(Message, MessageListener) This is where the container delegates to the actual ejb instance's onMessage method. 3) afterMessageDelivery(Message, MessageListener) Perform transaction cleanup and error handling. We use the EjbInvocation manager's thread-specific state to track the invocation across these three calls.
 */
public void beforeMessageDelivery(Method method,MessageDeliveryType deliveryType,boolean txImported,ResourceHandle resourceHandle){
  if (containerState != CONTAINER_STARTED) {
    String errorMsg=localStrings.getLocalString("String_Node_Str",appEJBName_ + "String_Node_Str",new Object[]{appEJBName_});
    throw new EJBException(errorMsg);
  }
  EjbInvocation invocation=createEjbInvocation();
  try {
    MessageBeanContextImpl context=(MessageBeanContextImpl)getContext(invocation);
    if (deliveryType == MessageDeliveryType.Timer) {
      invocation.isTimerCallback=true;
    }
    invocation.setOriginalContextClassLoader(Utility.setContextClassLoader(getClassLoader()));
    invocation.isMessageDriven=true;
    invocation.method=method;
    context.setState(BeanState.INVOKING);
    invocation.context=context;
    invocation.instance=context.getEJB();
    invocation.ejb=context.getEJB();
    invocation.container=this;
    boolean startTx=false;
    if (!txImported) {
      startTx=containerStartsTx(method);
    }
    invocation.containerStartsTx=startTx;
    this.invocationManager.preInvoke(invocation);
    if (startTx) {
      registerMessageBeanResource(resourceHandle);
    }
    preInvokeTx(invocation);
  }
 catch (  Throwable c) {
    if (containerState != CONTAINER_STARTED) {
      _logger.log(Level.SEVERE,"String_Node_Str",new Object[]{appEJBName_,c.toString()});
      _logger.log(Level.SEVERE,c.getClass().getName(),c);
    }
    invocation.exception=c;
  }
}

Fixed version (ground truth):
/** 
 * Actual message delivery happens in three steps : 1) beforeMessageDelivery(Message, MessageListener) This is our chance to make the message delivery itself part of the instance's global transaction. 2) onMessage(Message, MessageListener) This is where the container delegates to the actual ejb instance's onMessage method. 3) afterMessageDelivery(Message, MessageListener) Perform transaction cleanup and error handling. We use the EjbInvocation manager's thread-specific state to track the invocation across these three calls.
 */
public void beforeMessageDelivery(Method method,MessageDeliveryType deliveryType,boolean txImported,ResourceHandle resourceHandle){
  if (containerState != CONTAINER_STARTED) {
    String errorMsg=localStrings.getLocalString("String_Node_Str",appEJBName_ + "String_Node_Str",new Object[]{appEJBName_});
    throw new EJBException(errorMsg);
  }
  EjbInvocation invocation=createEjbInvocation();
  try {
    MessageBeanContextImpl context=(MessageBeanContextImpl)getContext(invocation);
    if (deliveryType == MessageDeliveryType.Timer) {
      invocation.isTimerCallback=true;
    }
    invocation.setOriginalContextClassLoader(Utility.setContextClassLoader(getClassLoader()));
    invocation.isMessageDriven=true;
    invocation.method=method;
    context.setState(BeanState.INVOKING);
    invocation.context=context;
    invocation.instance=context.getEJB();
    invocation.ejb=context.getEJB();
    invocation.container=this;
    boolean startTx=false;
    if (!txImported) {
      startTx=containerStartsTx(method);
    }
    invocation.setContainerStartsTx(startTx);
    this.invocationManager.preInvoke(invocation);
    if (startTx) {
      registerMessageBeanResource(resourceHandle);
    }
    preInvokeTx(invocation);
  }
 catch (  Throwable c) {
    if (containerState != CONTAINER_STARTED) {
      _logger.log(Level.SEVERE,"String_Node_Str",new Object[]{appEJBName_,c.toString()});
      _logger.log(Level.SEVERE,c.getClass().getName(),c);
    }
    invocation.exception=c;
  }
}