Buggy code:
public class ServerGroupDeploymentReplaceHandler implements OperationStepHandler , DescriptionProvider { public static final String OPERATION_NAME = REPLACE_DEPLOYMENT ; static final ModelNode getOperation ( ModelNode address ) { } private final HostFileRepository fileRepository ; private final ParametersValidator validator = new ParametersValidator ( ) ; public ServerGroupDeploymentReplaceHandler ( final HostFileRepository fileRepository ) { } @ Override public ModelNode getModelDescription ( Locale locale ) { } public void execute ( OperationContext context , ModelNode operation ) throws OperationFailedException { validator . validate ( operation ) ; String name = operation . require ( NAME ) . asString ( ) ; String toReplace = operation . require ( TO_REPLACE ) . asString ( ) ; if ( name . equals ( toReplace ) ) { throw ServerGroupDeploymentReplaceHandler . operationFailed ( DomainControllerMessages . MESSAGES . cannotUseSameValueForParameters ( ServerGroupDeploymentReplaceHandler . OPERATION_NAME , NAME , TO_REPLACE , ServerGroupDeploymentRedeployHandler . OPERATION_NAME , DeploymentFullReplaceHandler . OPERATION_NAME ) ) ; } final PathElement deploymentPath = PathElement . pathElement ( DEPLOYMENT , name ) ; final PathElement replacePath = PathElement . pathElement ( DEPLOYMENT , toReplace ) ; Resource domainDeployment ; try { <START_BUG> domainDeployment = context . getRootResource ( ) . requireChild ( deploymentPath ) ; <END_BUG> } catch ( NoSuchElementException e ) { throw ServerGroupDeploymentReplaceHandler . operationFailed ( DomainControllerMessages . MESSAGES . noDeploymentContentWithName ( name ) ) ; } final ModelNode deployment = domainDeployment . getModel ( ) ; for ( ModelNode content : deployment . require ( CONTENT ) . asList ( ) ) { if ( content . hasDefined ( HASH ) ) { byte [ ] hash = content . require ( HASH ) . asBytes ( ) ; fileRepository . getDeploymentFiles ( hash ) ; } } final Resource serverGroup = context . readResourceForUpdate ( EMPTY_ADDRESS ) ; if ( ! ( serverGroup . hasChild ( replacePath ) ) ) { throw ServerGroupDeploymentReplaceHandler . operationFailed ( DomainControllerMessages . MESSAGES . noDeploymentContentWithName ( toReplace ) ) ; } final Resource replaceResource = context . readResourceForUpdate ( EMPTY_ADDRESS . append ( replacePath ) ) ; final Resource deploymentResource ; if ( ! ( serverGroup . hasChild ( deploymentPath ) ) ) { final Resource resource = context . createResource ( EMPTY_ADDRESS . append ( deploymentPath ) ) ; final ModelNode deployNode = resource . getModel ( ) ; deployNode . set ( deployment ) ; deployNode . remove ( "content" ) ; deployNode . get ( ENABLED ) . set ( true ) ; } else { deploymentResource = context . readResourceForUpdate ( EMPTY_ADDRESS . append ( deploymentPath ) ) ; if ( deploymentResource . getModel ( ) . get ( ENABLED ) . asBoolean ( ) ) { throw ServerGroupDeploymentReplaceHandler . operationFailed ( DomainControllerMessages . MESSAGES . deploymentAlreadyStarted ( toReplace ) ) ; } } replaceResource . getModel ( ) . get ( ENABLED ) . set ( false ) ; context . completeStep ( ) ; } private static OperationFailedException operationFailed ( String msg ) { } }

Fix:
domainDeployment = context . readResourceFromRoot ( EMPTY_ADDRESS . append ( deploymentPath ) ) ;