Buggy code:
String callbackHandlerClassName = "default" ; String subjectFactoryClassName = "default" ; String authorizationManagerClassName = "default" ; String auditManagerClassName = "default" ; String identityTrustManagerClassName = "default" ; String mappingManagerClassName = "default" ; final ModelNode subModel = context . getSubModel ( ) ; if ( operation . hasDefined ( Constants . AUTHENTICATION_MANAGER_CLASS_NAME ) ) { authenticationManagerClassName = operation . get ( Constants . AUTHENTICATION_MANAGER_CLASS_NAME ) . asString ( ) ; subModel . get ( Constants . AUTHENTICATION_MANAGER_CLASS_NAME ) . set ( authenticationManagerClassName ) ; } final boolean deepCopySubject ; if ( operation . hasDefined ( Constants . DEEP_COPY_SUBJECT_MODE ) ) { deepCopySubject = operation . get ( Constants . DEEP_COPY_SUBJECT_MODE ) . asBoolean ( ) ; subModel . get ( Constants . DEEP_COPY_SUBJECT_MODE ) . set ( deepCopySubject ) ; } else { deepCopySubject = SecuritySubsystemAdd . DEFAULT_DEEP_COPY_OPERATION_MODE ; } if ( operation . hasDefined ( Constants . DEFAULT_CALLBACK_HANDLER_CLASS_NAME ) ) { callbackHandlerClassName = operation . get ( Constants . DEFAULT_CALLBACK_HANDLER_CLASS_NAME ) . asString ( ) ; subModel . get ( Constants . DEFAULT_CALLBACK_HANDLER_CLASS_NAME ) . set ( callbackHandlerClassName ) ; } if ( operation . hasDefined ( Constants . SUBJECT_FACTORY_CLASS_NAME ) ) { subjectFactoryClassName = operation . get ( Constants . SUBJECT_FACTORY_CLASS_NAME ) . asString ( ) ; subModel . get ( Constants . SUBJECT_FACTORY_CLASS_NAME ) . set ( subjectFactoryClassName ) ; } if ( operation . hasDefined ( Constants . AUTHORIZATION_MANAGER_CLASS_NAME ) ) { authorizationManagerClassName = operation . get ( Constants . AUTHORIZATION_MANAGER_CLASS_NAME ) . asString ( ) ; subModel . get ( Constants . AUTHORIZATION_MANAGER_CLASS_NAME ) . set ( authorizationManagerClassName ) ; } if ( operation . hasDefined ( Constants . AUDIT_MANAGER_CLASS_NAME ) ) { auditManagerClassName = operation . get ( Constants . AUDIT_MANAGER_CLASS_NAME ) . asString ( ) ; subModel . get ( Constants . AUDIT_MANAGER_CLASS_NAME ) . set ( auditManagerClassName ) ; } if ( operation . hasDefined ( Constants . IDENTITY_TRUST_MANAGER_CLASS_NAME ) ) { identityTrustManagerClassName = operation . get ( Constants . IDENTITY_TRUST_MANAGER_CLASS_NAME ) . asString ( ) ; subModel . get ( Constants . IDENTITY_TRUST_MANAGER_CLASS_NAME ) . set ( identityTrustManagerClassName ) ; } if ( operation . hasDefined ( Constants . MAPPING_MANAGER_CLASS_NAME ) ) { mappingManagerClassName = operation . get ( Constants . MAPPING_MANAGER_CLASS_NAME ) . asString ( ) ; subModel . get ( Constants . MAPPING_MANAGER_CLASS_NAME ) . set ( mappingManagerClassName ) ; } subModel . get ( Constants . SECURITY_DOMAIN ) . setEmptyObject ( ) ; final String resolvedAuthenticationManagerClassName ; if ( "default" . equals ( authenticationManagerClassName ) ) { resolvedAuthenticationManagerClassName = SecuritySubsystemAdd . AUTHENTICATION_MANAGER ; } else { resolvedAuthenticationManagerClassName = authenticationManagerClassName ; } final String resolvedCallbackHandlerClassName ; if ( "default" . equals ( callbackHandlerClassName ) ) { resolvedCallbackHandlerClassName = SecuritySubsystemAdd . CALLBACK_HANDLER ; } else { resolvedCallbackHandlerClassName = callbackHandlerClassName ; } final String resolvedAuthorizationManagerClassName ; if ( "default" . equals ( authorizationManagerClassName ) ) { resolvedAuthorizationManagerClassName = SecuritySubsystemAdd . AUTHORIZATION_MANAGER ; } else { resolvedAuthorizationManagerClassName = authorizationManagerClassName ; } final String resolvedAuditManagerClassName ; if ( "default" . equals ( auditManagerClassName ) ) { resolvedAuditManagerClassName = SecuritySubsystemAdd . AUDIT_MANAGER ; } else { resolvedAuditManagerClassName = auditManagerClassName ; } final String resolvedIdentityTrustManagerClassName ; if ( "default" . equals ( identityTrustManagerClassName ) ) { resolvedIdentityTrustManagerClassName = SecuritySubsystemAdd . IDENTITY_TRUST_MANAGER ; } else { resolvedIdentityTrustManagerClassName = identityTrustManagerClassName ; } final String resolvedMappingManagerClassName ; if ( "default" . equals ( mappingManagerClassName ) ) { resolvedMappingManagerClassName = SecuritySubsystemAdd . MAPPING_MANAGER ; } else { resolvedMappingManagerClassName = mappingManagerClassName ; } final String resolvedSubjectFactoryClassName ; if ( "default" . equals ( subjectFactoryClassName ) ) { resolvedSubjectFactoryClassName = SecuritySubsystemAdd . SUBJECT_FACTORY ; } else { resolvedSubjectFactoryClassName = subjectFactoryClassName ; } if ( context instanceof BootOperationContext ) { final BootOperationContext updateContext = ( ( BootOperationContext ) ( context ) ) ; context . getRuntimeContext ( ) . setRuntimeTask ( new RuntimeTask ( ) { public void execute ( RuntimeTaskContext context ) throws OperationFailedException { updateContext . addDeploymentProcessor ( DEPENDENCIES , DEPENDENCIES_MODULE , new SecurityDependencyProcessor ( ) ) ; SecuritySubsystemAdd . log . info ( "Activating<seq2seq4repair_space>Security<seq2seq4repair_space>Subsystem" ) ; final ServiceTarget target = context . getServiceTarget ( ) ; final SecurityBootstrapService bootstrapService = new SecurityBootstrapService ( ) ; target . addService ( SERVICE_NAME , bootstrapService ) . setInitialMode ( ACTIVE ) . install ( ) ; final SecurityDomainJndiInjectable securityDomainJndiInjectable = new SecurityDomainJndiInjectable ( ) ; final BinderService binderService = new BinderService ( "jaas" ) ; target . addService ( JAVA_CONTEXT_SERVICE_NAME . append ( "jboss" , "jaas" ) , binderService ) . addInjection ( binderService . getManagedObjectInjector ( ) , securityDomainJndiInjectable ) . addDependency ( JAVA_CONTEXT_SERVICE_NAME . append ( "jboss" ) , NamingStore . class , binderService . getNamingStoreInjector ( ) ) . addDependency ( SecurityManagementService . SERVICE_NAME , ISecurityManagement . class , securityDomainJndiInjectable . getSecurityManagementInjector ( ) ) . setInitialMode ( ACTIVE ) . install ( ) ; final SecurityManagementService securityManagementService = new SecurityManagementService ( resolvedAuthenticationManagerClassName , deepCopySubject , resolvedCallbackHandlerClassName , resolvedAuthorizationManagerClassName , resolvedAuditManagerClassName , resolvedIdentityTrustManagerClassName , resolvedMappingManagerClassName ) ; <START_BUG> target . addService ( SecurityManagementService . SERVICE_NAME , securityManagementService ) . addDependency ( REQUIRED , EmbeddedCacheManagerService . getServiceName ( SecuritySubsystemAdd . CACHE_CONTAINER_NAME ) , EmbeddedCacheManager . class , securityManagementService . getAuthenticationCacheManagerInjector ( ) ) . setInitialMode ( ACTIVE ) . install ( ) ; <END_BUG> final SubjectFactoryService subjectFactoryService = new SubjectFactoryService ( resolvedSubjectFactoryClassName ) ; target . addService ( SubjectFactoryService . SERVICE_NAME , subjectFactoryService ) . addDependency ( SecurityManagementService . SERVICE_NAME , ISecurityManagement . class , subjectFactoryService . getSecurityManagementInjector ( ) ) . setInitialMode ( ACTIVE ) . install ( ) ; Configuration loginConfig = XMLLoginConfigImpl . getInstance ( ) ; final JaasConfigurationService jaasConfigurationService = new JaasConfigurationService ( loginConfig ) ; target . addService ( JaasConfigurationService . SERVICE_NAME , jaasConfigurationService ) . setInitialMode ( ACTIVE ) . install ( ) ; resultHandler . handleResultComplete ( ) ; } } ) ; } else { resultHandler . handleResultComplete ( ) ; } final ModelNode compensatingOperation = Util . getResourceRemoveOperation ( operation . require ( OP_ADDR ) ) ; return new org . jboss . as . controller . BasicOperationResult ( compensatingOperation ) ; } }

Fix:
target . addService ( SecurityManagementService . SERVICE_NAME , securityManagementService ) . addDependency ( OPTIONAL , EmbeddedCacheManagerService . getServiceName ( SecuritySubsystemAdd . CACHE_CONTAINER_NAME ) , EmbeddedCacheManager . class , securityManagementService . getAuthenticationCacheManagerInjector ( ) ) . setInitialMode ( ACTIVE ) . install ( ) ;