Buggy code:
public class StatefulComponentInstanceInterceptor extends AbstractEJBInterceptor { private static final Logger log = Logger . getLogger ( StatefulComponentInstanceInterceptor . class ) ; @ Override public Object processInvocation ( InterceptorContext context ) throws Exception { StatefulSessionComponent component = getComponent ( context , StatefulSessionComponent . class ) ; <START_BUG> SessionID sessionId = ( ( SessionID ) ( context . getPrivateData ( SESSION_ID_KEY ) ) ) ; <END_BUG> if ( sessionId == null ) { throw EjbMessages . MESSAGES . statefulSessionIdIsNull ( component . getComponentName ( ) ) ; } EjbLogger . ROOT_LOGGER . debug ( ( "Looking<seq2seq4repair_space>for<seq2seq4repair_space>stateful<seq2seq4repair_space>component<seq2seq4repair_space>instance<seq2seq4repair_space>with<seq2seq4repair_space>session<seq2seq4repair_space>id:<seq2seq4repair_space>" + sessionId ) ) ; StatefulSessionComponentInstance instance = component . getCache ( ) . get ( sessionId ) ; if ( instance == null ) { throw new javax . ejb . NoSuchEJBException ( ( ( ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>find<seq2seq4repair_space>SFSB<seq2seq4repair_space>" + ( component . getComponentName ( ) ) ) + "<seq2seq4repair_space>with<seq2seq4repair_space>" ) + sessionId ) ) ; } try { context . putPrivateData ( ComponentInstance . class , instance ) ; return context . proceed ( ) ; } catch ( Exception ex ) { if ( ( component . getApplicationException ( ex . getClass ( ) , context . getMethod ( ) ) ) != null ) { throw ex ; } if ( ( ex instanceof ConcurrentAccessTimeoutException ) || ( ex instanceof ConcurrentAccessException ) ) { throw ex ; } if ( ! ( ex instanceof RemoveException ) ) { if ( ( ex instanceof RuntimeException ) || ( ex instanceof RemoteException ) ) { if ( EjbLogger . ROOT_LOGGER . isTraceEnabled ( ) ) EjbLogger . ROOT_LOGGER . trace ( ( ( "Removing<seq2seq4repair_space>bean<seq2seq4repair_space>" + sessionId ) + "<seq2seq4repair_space>because<seq2seq4repair_space>of<seq2seq4repair_space>exception" ) , ex ) ; instance . discard ( ) ; } } throw ex ; } catch ( final Error e ) { if ( EjbLogger . ROOT_LOGGER . isTraceEnabled ( ) ) EjbLogger . ROOT_LOGGER . trace ( ( ( "Removing<seq2seq4repair_space>bean<seq2seq4repair_space>" + sessionId ) + "<seq2seq4repair_space>because<seq2seq4repair_space>of<seq2seq4repair_space>error" ) , e ) ; instance . discard ( ) ; throw e ; } catch ( final Throwable t ) { if ( EjbLogger . ROOT_LOGGER . isTraceEnabled ( ) ) EjbLogger . ROOT_LOGGER . trace ( ( ( "Removing<seq2seq4repair_space>bean<seq2seq4repair_space>" + sessionId ) + "<seq2seq4repair_space>because<seq2seq4repair_space>of<seq2seq4repair_space>Throwable" ) , t ) ; instance . discard ( ) ; throw new RuntimeException ( t ) ; } finally { context . putPrivateData ( ComponentInstance . class , null ) ; } } static StatefulSessionComponentInstance getComponentInstance ( InterceptorContext context ) { } public static class Factory implements InterceptorFactory { public static final InterceptorFactory INSTANCE = new StatefulComponentInstanceInterceptor . Factory ( ) ; private Factory ( ) { } @ Override public Interceptor create ( InterceptorFactoryContext context ) { } } }

Fix:
SessionID sessionId = ( ( SessionID ) ( context . getPrivateData ( SessionID . class ) ) ) ;