Buggy code:
public class RaRemove implements OperationStepHandler { static final RaRemove INSTANCE = new RaRemove ( ) ; public void execute ( OperationContext context , ModelNode operation ) throws OperationFailedException { final ModelNode opAddr = operation . require ( OP_ADDR ) ; final String idName = PathAddress . pathAddress ( opAddr ) . getLastElement ( ) . getValue ( ) ; <START_BUG> final ModelNode model = context . readResource ( EMPTY_ADDRESS , false ) . getModel ( ) ; <END_BUG> final String archiveName ; final boolean isModule ; if ( model . get ( Constants . ARCHIVE . getName ( ) ) . isDefined ( ) ) { isModule = false ; archiveName = Constants . ARCHIVE . resolveModelAttribute ( context , model ) . asString ( ) ; } else { archiveName = null ; isModule = true ; } final ModelNode compensating = Util . getEmptyOperation ( ADD , opAddr ) ; if ( model . hasDefined ( Constants . RESOURCEADAPTERS_NAME ) ) { for ( ModelNode raNode : model . get ( Constants . RESOURCEADAPTERS_NAME ) . asList ( ) ) { ModelNode raCompensatingNode = raNode . clone ( ) ; compensating . get ( Constants . RESOURCEADAPTERS_NAME ) . add ( raCompensatingNode ) ; } } context . removeResource ( EMPTY_ADDRESS ) ; context . addStep ( new OperationStepHandler ( ) { public void execute ( OperationContext context , ModelNode operation ) throws OperationFailedException { final boolean wasActive ; if ( isModule ) { wasActive = RaOperationUtil . removeIfActive ( context , null , idName ) ; } else { wasActive = RaOperationUtil . removeIfActive ( context , archiveName , idName ) ; if ( wasActive ) { context . reloadRequired ( ) ; context . completeStep ( new OperationContext . RollbackHandler ( ) { @ Override public void handleRollback ( OperationContext context , ModelNode operation ) { context . revertReloadRequired ( ) ; } } ) ; return ; } } ServiceName raServiceName = ServiceName . of ( RA_SERVICE , idName ) ; ServiceController < ? > serviceController = context . getServiceRegistry ( false ) . getService ( raServiceName ) ; final ModifiableResourceAdapter resourceAdapter ; if ( serviceController != null ) { resourceAdapter = ( ( ModifiableResourceAdapter ) ( serviceController . getValue ( ) ) ) ; } else { resourceAdapter = null ; } final List < ServiceName > serviceNameList = context . getServiceRegistry ( false ) . getServiceNames ( ) ; for ( ServiceName name : serviceNameList ) { if ( raServiceName . isParentOf ( name ) ) { context . removeService ( name ) ; } } if ( model . get ( Constants . MODULE . getName ( ) ) . isDefined ( ) ) { ServiceName deployerServiceName = RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX . append ( idName ) ; context . removeService ( deployerServiceName ) ; ServiceName inactiveServiceName = INACTIVE_RESOURCE_ADAPTER_SERVICE . append ( idName ) ; context . removeService ( inactiveServiceName ) ; } context . removeService ( raServiceName ) ; context . completeStep ( new OperationContext . RollbackHandler ( ) { @ Override public void handleRollback ( OperationContext context , ModelNode operation ) { if ( resourceAdapter != null ) { List < ServiceController < ? > > newControllers = new LinkedList < ServiceController < ? > > ( ) ; if ( model . get ( Constants . ARCHIVE . getName ( ) ) . isDefined ( ) ) { RaOperationUtil . installRaServices ( context , new ServiceVerificationHandler ( ) , idName , resourceAdapter , newControllers ) ; } else { try { RaOperationUtil . installRaServicesAndDeployFromModule ( context , new ServiceVerificationHandler ( ) , idName , resourceAdapter , archiveName , newControllers ) ; } catch ( OperationFailedException e ) { } } try { if ( wasActive ) { if ( isModule ) { RaOperationUtil . activate ( context , idName , null ) ; } else { RaOperationUtil . activate ( context , archiveName , null ) ; } } } catch ( OperationFailedException e ) { } } } } ) ; } } , RUNTIME ) ; context . stepCompleted ( ) ; } }

Fix:
final ModelNode model = context . readModel ( EMPTY_ADDRESS ) ;