Buggy code:
public class BundleStartTracker extends AbstractService < BundleStartTracker > { private static final Logger log = Logger . getLogger ( "org.jboss.as.osgi" ) ; public static final ServiceName SERVICE_NAME = FRAMEWORK_BASE_NAME . append ( "starttracker" ) ; private final InjectedValue < PackageAdmin > injectedPackageAdmin = new InjectedValue < PackageAdmin > ( ) ; private final Map < ServiceName , BundleStartTracker . Tuple > pendingServices = new ConcurrentHashMap < ServiceName , BundleStartTracker . Tuple > ( ) ; private final Map < ServiceName , BundleStartTracker . Tuple > startedServices = new ConcurrentHashMap < ServiceName , BundleStartTracker . Tuple > ( ) ; private ServiceContainer serviceContainer ; public static void addService ( ServiceTarget serviceTarget ) { } private BundleStartTracker ( ) { } @ Override public void start ( StartContext context ) throws StartException { } @ Override public BundleStartTracker getValue ( ) throws IllegalStateException { } @ SuppressWarnings ( "unchecked" ) void addInstalledBundle ( ServiceName serviceName , Deployment deployment ) { ServiceController < Bundle > controller = ( ( ServiceController < Bundle > ) ( serviceContainer . getRequiredService ( serviceName ) ) ) ; pendingServices . put ( serviceName , new BundleStartTracker . Tuple ( controller , deployment ) ) ; controller . addListener ( new org . jboss . msc . service . AbstractServiceListener < Bundle > ( ) { @ Override public void listenerAdded ( ServiceController < ? extends Bundle > controller ) { State state = controller . getState ( ) ; if ( ( state == ( State . UP ) ) || ( state == ( State . START_FAILED ) ) ) processService ( controller ) ; } @ Override public void serviceStarted ( ServiceController < ? extends Bundle > controller ) { ServiceName key = controller . getName ( ) ; BundleStartTracker . Tuple value = pendingServices . get ( key ) ; startedServices . put ( key , value ) ; processService ( controller ) ; } @ Override public void serviceFailed ( ServiceController < ? extends Bundle > controller , StartException reason ) { processService ( controller ) ; } private void processService ( ServiceController < ? extends Bundle > controller ) { controller . removeListener ( this ) ; Map < ServiceName , BundleStartTracker . Tuple > bundlesToStart = null ; synchronized ( this ) { ServiceName key = controller . getName ( ) ; pendingServices . remove ( key ) ; if ( pendingServices . isEmpty ( ) ) { bundlesToStart = new HashMap < ServiceName , BundleStartTracker . Tuple > ( startedServices ) ; startedServices . clear ( ) ; } } if ( bundlesToStart != null ) { PackageAdmin packageAdmin = injectedPackageAdmin . getValue ( ) ; for ( BundleStartTracker . Tuple tuple : bundlesToStart . values ( ) ) { Bundle bundle = tuple . controller . getValue ( ) ; Deployment dep = tuple . deployment ; if ( dep . isAutoStart ( ) ) { try { int bundleType = packageAdmin . getBundleType ( bundle ) ; if ( bundleType != ( PackageAdmin . BUNDLE_TYPE_FRAGMENT ) ) { <START_BUG> bundle . start ( ) ; <END_BUG> } } catch ( BundleException ex ) { BundleStartTracker . log . errorf ( ex , "Cannot<seq2seq4repair_space>start<seq2seq4repair_space>bundle:<seq2seq4repair_space>%s" , bundle ) ; } } } } } } ) ; } private static final class Tuple { private ServiceController < ? extends Bundle > controller ; private Deployment deployment ; Tuple ( ServiceController < ? extends Bundle > controller , Deployment deployment ) { } } }

Fix:
bundle . start ( Bundle . START_TRANSIENT ) ;