Buggy code:
final XADataSourceConfigService xaDataSourceConfigService = new XADataSourceConfigService ( dataSourceConfig ) ; final ServiceBuilder < ? > builder = serviceTarget . addService ( xaDataSourceConfigServiceName , xaDataSourceConfigService ) ; if ( verificationHandler != null ) { builder . addListener ( verificationHandler ) ; } final DsSecurity dsSecurityConfig = dataSourceConfig . getSecurity ( ) ; if ( dsSecurityConfig != null ) { final String securityDomainName = dsSecurityConfig . getSecurityDomain ( ) ; if ( securityDomainName != null ) { builder . addDependency ( SERVICE_NAME . append ( securityDomainName ) ) ; } } int propertiesCount = 0 ; for ( ServiceName name : serviceNames ) { if ( xaDataSourceConfigServiceName . append ( "xa-datasource-properties" ) . isParentOf ( name ) ) { final ServiceController < ? > xaConfigPropertyController = registry . getService ( name ) ; XaDataSourcePropertiesService xaPropService = ( ( XaDataSourcePropertiesService ) ( xaConfigPropertyController . getService ( ) ) ) ; if ( ! ( UP . equals ( xaConfigPropertyController . getState ( ) ) ) ) { propertiesCount ++ ; xaConfigPropertyController . setMode ( ACTIVE ) ; builder . addDependency ( name , String . class , xaDataSourceConfigService . getXaDataSourcePropertyInjector ( xaPropService . getName ( ) ) ) ; } else { throw new OperationFailedException ( new ModelNode ( ) . set ( MESSAGES . serviceAlreadyStarted ( "Data-source.xa-config-property" , name ) ) ) ; } } } if ( propertiesCount == 0 ) { throw MESSAGES . xaDataSourcePropertiesNotPresent ( ) ; } controllers . add ( builder . install ( ) ) ; } else { final ModifiableDataSource dataSourceConfig ; try { dataSourceConfig = DataSourceModelNodeUtil . from ( context , model , dsName ) ; } catch ( ValidateException e ) { throw new OperationFailedException ( e , new ModelNode ( ) . set ( MESSAGES . failedToCreate ( "DataSource" , operation , e . getLocalizedMessage ( ) ) ) ) ; } final ServiceName dataSourceCongServiceName = DataSourceConfigService . SERVICE_NAME_BASE . append ( dsName ) ; final DataSourceConfigService configService = new DataSourceConfigService ( dataSourceConfig ) ; final ServiceBuilder < ? > builder = serviceTarget . addService ( dataSourceCongServiceName , configService ) ; if ( verificationHandler != null ) { builder . addListener ( verificationHandler ) ; } final DsSecurity dsSecurityConfig = dataSourceConfig . getSecurity ( ) ; if ( dsSecurityConfig != null ) { final String securityDomainName = dsSecurityConfig . getSecurityDomain ( ) ; if ( securityDomainName != null ) { builder . addDependency ( SERVICE_NAME . append ( securityDomainName ) ) ; } } for ( ServiceName name : serviceNames ) { if ( dataSourceCongServiceName . append ( "connection-properties" ) . isParentOf ( name ) ) { final ServiceController < ? > dataSourceController = registry . getService ( name ) ; ConnectionPropertiesService connPropService = ( ( ConnectionPropertiesService ) ( dataSourceController . getService ( ) ) ) ; if ( ! ( UP . equals ( dataSourceController . getState ( ) ) ) ) { dataSourceController . setMode ( ACTIVE ) ; builder . addDependency ( name , String . class , configService . getConnectionPropertyInjector ( connPropService . getName ( ) ) ) ; } else { throw new OperationFailedException ( new ModelNode ( ) . set ( MESSAGES . serviceAlreadyStarted ( "Data-source.connectionProperty" , name ) ) ) ; } } } controllers . add ( builder . install ( ) ) ; } final ServiceName dataSourceServiceName = AbstractDataSourceService . SERVICE_NAME_BASE . append ( jndiName ) ; final ServiceController < ? > dataSourceController = registry . getService ( dataSourceServiceName ) ; if ( dataSourceController != null ) { if ( ! ( UP . equals ( dataSourceController . getState ( ) ) ) ) { dataSourceController . setMode ( ACTIVE ) ; } else { throw new OperationFailedException ( new ModelNode ( ) . set ( MESSAGES . serviceAlreadyStarted ( "Data-source" , dsName ) ) ) ; } } else { throw new OperationFailedException ( new ModelNode ( ) . set ( MESSAGES . serviceNotAvailable ( "Data-source" , dsName ) ) ) ; } final DataSourceReferenceFactoryService referenceFactoryService = new DataSourceReferenceFactoryService ( ) ; final ServiceName referenceFactoryServiceName = DataSourceReferenceFactoryService . SERVICE_NAME_BASE . append ( dsName ) ; final ServiceBuilder < ? > referenceBuilder = serviceTarget . addService ( referenceFactoryServiceName , referenceFactoryService ) . addDependency ( dataSourceServiceName , DataSource . class , referenceFactoryService . getDataSourceInjector ( ) ) ; if ( verificationHandler != null ) { referenceBuilder . addListener ( verificationHandler ) ; } controllers . add ( referenceBuilder . install ( ) ) ; final ContextNames . BindInfo bindInfo = ContextNames . bindInfoFor ( jndiName ) ; final BinderService binderService = new BinderService ( bindInfo . getBindName ( ) ) ; final ServiceBuilder < ? > binderBuilder = serviceTarget . addService ( bindInfo . getBinderServiceName ( ) , binderService ) . addDependency ( referenceFactoryServiceName , ManagedReferenceFactory . class , binderService . getManagedObjectInjector ( ) ) . addDependency ( bindInfo . getParentContextServiceName ( ) , ServiceBasedNamingStore . class , binderService . getNamingStoreInjector ( ) ) . addListener ( new org . jboss . msc . service . AbstractServiceListener < Object > ( ) { public void transition ( final ServiceController < ? extends Object > controller , final ServiceController . Transition transition ) { switch ( transition ) { case STARTING_to_UP : { SUBSYSTEM_DATASOURCES_LOGGER . boundDataSource ( jndiName ) ; break ; } <START_BUG> case START_REQUESTED_to_DOWN : <END_BUG> { SUBSYSTEM_DATASOURCES_LOGGER . unboundDataSource ( jndiName ) ; break ; } case REMOVING_to_REMOVED : { SUBSYSTEM_DATASOURCES_LOGGER . debugf ( "Removed<seq2seq4repair_space>JDBC<seq2seq4repair_space>Data-source<seq2seq4repair_space>[%s]" , jndiName ) ; break ; } } } } ) ; binderBuilder . setInitialMode ( ACTIVE ) ; if ( verificationHandler != null ) { binderBuilder . addListener ( verificationHandler ) ; } controllers . add ( binderBuilder . install ( ) ) ; } public static DataSourceEnable getLocalInstance ( ) { } public boolean isXa ( ) { } protected void rollbackRuntime ( OperationContext context , final ModelNode operation , final ModelNode model , List < ServiceController < ? > > controllers ) { } }

Fix:
case STOPPING_to_DOWN :