Buggy code:
root . registerOperationHandler ( SnapshotTakeHandler . OPERATION_NAME , snapshotTake , snapshotTake , false ) ; root . registerOperationHandler ( ServerRestartRequiredHandler . OPERATION_NAME , ServerRestartRequiredHandler . INSTANCE , ServerRestartRequiredHandler . INSTANCE , false ) ; root . registerReadOnlyAttribute ( PROCESS_STATE , new org . jboss . as . controller . operations . common . ProcessStateAttributeHandler ( processState ) , RUNTIME ) ; root . registerReadOnlyAttribute ( PROCESS_TYPE , ProcessTypeHandler . INSTANCE , RUNTIME ) ; RunningModeReadHandler . createAndRegister ( runningModeControl , root ) ; root . registerOperationHandler ( ResolveExpressionHandler . OPERATION_NAME , ResolveExpressionHandler . INSTANCE , ResolveExpressionHandler . INSTANCE , EnumSet . of ( READ_ONLY ) ) ; root . registerOperationHandler ( SpecifiedInterfaceResolveHandler . OPERATION_NAME , SpecifiedInterfaceResolveHandler . INSTANCE , SpecifiedInterfaceResolveHandler . INSTANCE ) ; root . registerOperationHandler ( RootResourceHack . NAME , RootResourceHack . INSTANCE , RootResourceHack . INSTANCE , false , OperationEntry . EntryType . PRIVATE ) ; if ( serverEnvironment != null ) { if ( ( serverEnvironment . getLaunchType ( ) ) != ( LaunchType . DOMAIN ) ) { ProcessReloadHandler reloadHandler = new ProcessReloadHandler ( Services . JBOSS_AS , runningModeControl , ServerDescriptions . getResourceDescriptionResolver ( "server" ) ) ; root . registerOperationHandler ( ProcessReloadHandler . OPERATION_NAME , reloadHandler , reloadHandler ) ; } if ( ( serverEnvironment . getLaunchType ( ) ) == ( LaunchType . STANDALONE ) ) { root . registerOperationHandler ( ServerShutdownHandler . OPERATION_NAME , ServerShutdownHandler . INSTANCE , ServerShutdownHandler . INSTANCE , false ) ; } root . registerReadOnlyAttribute ( LAUNCH_TYPE , new org . jboss . as . server . operations . LaunchTypeHandler ( serverEnvironment . getLaunchType ( ) ) , RUNTIME ) ; root . registerSubModel ( ServerEnvironmentResourceDescription . of ( serverEnvironment ) ) ; } ManagementResourceRegistration sysProps = root . registerSubModel ( PathElement . pathElement ( SYSTEM_PROPERTY ) , SYSTEM_PROPERTIES_PROVIDER ) ; sysProps . registerOperationHandler ( SystemPropertyAddHandler . OPERATION_NAME , INSTANCE_WITHOUT_BOOTTIME , INSTANCE_WITHOUT_BOOTTIME , false ) ; sysProps . registerOperationHandler ( SystemPropertyRemoveHandler . OPERATION_NAME , SystemPropertyRemoveHandler . INSTANCE , SystemPropertyRemoveHandler . INSTANCE , false ) ; sysProps . registerReadWriteAttribute ( VALUE , null , SystemPropertyValueWriteAttributeHandler . INSTANCE , CONFIGURATION ) ; ManagementResourceRegistration vault = root . registerSubModel ( PathElement . pathElement ( CORE_SERVICE , VAULT ) , VAULT_PROVIDER ) ; VaultAddHandler vah = new VaultAddHandler ( vaultReader ) ; vault . registerOperationHandler ( VaultAddHandler . OPERATION_NAME , vah , vah , false ) ; VaultRemoveHandler vrh = new VaultRemoveHandler ( vaultReader ) ; vault . registerOperationHandler ( VaultRemoveHandler . OPERATION_NAME , vrh , vrh , false ) ; VaultWriteAttributeHandler . INSTANCE . registerAttributes ( vault ) ; ManagementResourceRegistration management = root . registerSubModel ( PathElement . pathElement ( CORE_SERVICE , MANAGEMENT ) , MANAGEMENT_WITH_INTERFACES_PROVIDER ) ; management . registerSubModel ( SecurityRealmResourceDefinition . INSTANCE ) ; management . registerSubModel ( LdapConnectionResourceDefinition . INSTANCE ) ; management . registerSubModel ( NativeManagementResourceDefinition . INSTANCE ) ; management . registerSubModel ( NativeRemotingManagementResourceDefinition . INSTANCE ) ; management . registerSubModel ( HttpManagementResourceDefinition . INSTANCE ) ; ManagementResourceRegistration serviceContainer = root . registerSubModel ( PathElement . pathElement ( CORE_SERVICE , SERVICE_CONTAINER ) , SERVICE_CONTAINER_PROVIDER ) ; serviceContainer . registerOperationHandler ( DumpServicesHandler . OPERATION_NAME , DumpServicesHandler . INSTANCE , DumpServicesHandler . INSTANCE , false ) ; PlatformMBeanResourceRegistrar . registerPlatformMBeanResources ( root ) ; ManagementResourceRegistration paths = root . registerSubModel ( PathElement . pathElement ( PATH ) , SPECIFIED_PATH_PROVIDER ) ; paths . registerOperationHandler ( SpecifiedPathAddHandler . OPERATION_NAME , SpecifiedPathAddHandler . INSTANCE , SpecifiedPathAddHandler . INSTANCE , false ) ; paths . registerOperationHandler ( SpecifiedPathRemoveHandler . OPERATION_NAME , SpecifiedPathRemoveHandler . INSTANCE , SpecifiedPathRemoveHandler . INSTANCE , false ) ; ManagementResourceRegistration interfaces = root . registerSubModel ( PathElement . pathElement ( INTERFACE ) , SPECIFIED_INTERFACE_PROVIDER ) ; interfaces . registerOperationHandler ( SpecifiedInterfaceAddHandler . OPERATION_NAME , SpecifiedInterfaceAddHandler . INSTANCE , SpecifiedInterfaceAddHandler . INSTANCE , false ) ; interfaces . registerOperationHandler ( SpecifiedInterfaceRemoveHandler . OPERATION_NAME , SpecifiedInterfaceRemoveHandler . INSTANCE , SpecifiedInterfaceRemoveHandler . INSTANCE , false ) ; InterfaceCriteriaWriteHandler . register ( interfaces ) ; interfaces . registerReadOnlyAttribute ( RESOLVED_ADDRESS , NetworkInterfaceRuntimeHandler . INSTANCE , RUNTIME ) ; interfaces . registerReadOnlyAttribute ( CRITERIA , InterfaceLegacyCriteriaReadHandler . INSTANCE , Storage . CONFIGURATION ) ; interfaces . registerOperationHandler ( SpecifiedInterfaceResolveHandler . OPERATION_NAME , SpecifiedInterfaceResolveHandler . INSTANCE , SpecifiedInterfaceResolveHandler . INSTANCE ) ; ManagementResourceRegistration socketGroup = root . registerSubModel ( new org . jboss . as . controller . resource . SocketBindingGroupResourceDefinition ( BindingGroupAddHandler . INSTANCE , SocketBindingGroupRemoveHandler . INSTANCE , false ) ) ; socketGroup . registerSubModel ( SocketBindingResourceDefinition . INSTANCE ) ; socketGroup . registerSubModel ( RemoteDestinationOutboundSocketBindingResourceDefinition . INSTANCE ) ; socketGroup . registerSubModel ( LocalDestinationOutboundSocketBindingResourceDefinition . INSTANCE ) ; ManagementResourceRegistration deployments = root . registerSubModel ( PathElement . pathElement ( DEPLOYMENT ) , DEPLOYMENT_PROVIDER ) ; DeploymentAddHandler dah = new DeploymentAddHandler ( contentRepository ) ; deployments . registerOperationHandler ( DeploymentAddHandler . OPERATION_NAME , dah , dah , false ) ; <START_BUG> DeploymentRemoveHandler dremh = new DeploymentRemoveHandler ( contentRepository , ( ( serverEnvironment != null ) && ( serverEnvironment . isStandalone ( ) ) ) ) ; <END_BUG> deployments . registerOperationHandler ( DeploymentRemoveHandler . OPERATION_NAME , dremh , dremh , false ) ; deployments . registerOperationHandler ( DeploymentDeployHandler . OPERATION_NAME , DeploymentDeployHandler . INSTANCE , DeploymentDeployHandler . INSTANCE , false ) ; deployments . registerOperationHandler ( DeploymentUndeployHandler . OPERATION_NAME , DeploymentUndeployHandler . INSTANCE , DeploymentUndeployHandler . INSTANCE , false ) ; deployments . registerOperationHandler ( DeploymentRedeployHandler . OPERATION_NAME , DeploymentRedeployHandler . INSTANCE , DeploymentRedeployHandler . INSTANCE , false ) ; deployments . registerMetric ( ATTRIBUTE_NAME , DeploymentStatusHandler . INSTANCE ) ; deployments . registerSubModel ( PathElement . pathElement ( SUBDEPLOYMENT ) , SUBDEPLOYMENT_PROVIDER ) ; root . registerSubModel ( new org . jboss . as . controller . extension . ExtensionResourceDefinition ( extensionRegistry , parallelBoot ) ) ; extensionRegistry . setProfileResourceRegistration ( root ) ; extensionRegistry . setDeploymentsResourceRegistration ( deployments ) ; root . registerOperationHandler ( DeployerChainAddHandler . NAME , DeployerChainAddHandler . INSTANCE , DeployerChainAddHandler . INSTANCE , false , PRIVATE ) ; } static ProcessType getProcessType ( ServerEnvironment serverEnvironment ) { } }

Fix:
DeploymentRemoveHandler dremh = new DeploymentRemoveHandler ( contentRepository ) ;