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 ( INSTANCE ) ) ) ; <END_BUG> if ( sessionId == null ) { throw new IllegalStateException ( ( "Session<seq2seq4repair_space>id<seq2seq4repair_space>hasn't<seq2seq4repair_space>been<seq2seq4repair_space>set<seq2seq4repair_space>for<seq2seq4repair_space>stateful<seq2seq4repair_space>component:<seq2seq4repair_space>" + ( component . getComponentName ( ) ) ) ) ; } StatefulComponentInstanceInterceptor . log . 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 ) ; 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 RuntimeException ) || ( ex instanceof RemoteException ) ) { if ( StatefulComponentInstanceInterceptor . log . isTraceEnabled ( ) ) StatefulComponentInstanceInterceptor . log . trace ( ( ( "Removing<seq2seq4repair_space>bean<seq2seq4repair_space>" + sessionId ) + "<seq2seq4repair_space>because<seq2seq4repair_space>of<seq2seq4repair_space>exception" ) , ex ) ; component . getCache ( ) . discard ( sessionId ) ; } throw ex ; } catch ( final Error e ) { if ( StatefulComponentInstanceInterceptor . log . isTraceEnabled ( ) ) StatefulComponentInstanceInterceptor . log . trace ( ( ( "Removing<seq2seq4repair_space>bean<seq2seq4repair_space>" + sessionId ) + "<seq2seq4repair_space>because<seq2seq4repair_space>of<seq2seq4repair_space>error" ) , e ) ; component . getCache ( ) . discard ( sessionId ) ; throw e ; } catch ( final Throwable t ) { if ( StatefulComponentInstanceInterceptor . log . isTraceEnabled ( ) ) StatefulComponentInstanceInterceptor . log . trace ( ( ( "Removing<seq2seq4repair_space>bean<seq2seq4repair_space>" + sessionId ) + "<seq2seq4repair_space>because<seq2seq4repair_space>of<seq2seq4repair_space>Throwable" ) , t ) ; component . getCache ( ) . discard ( sessionId ) ; 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 ( SESSION_ID_KEY ) ) ) ;