Buggy code:
ServiceName authorizationName = null ; ModelNode authTruststore = null ; if ( plugIns != null ) { plugInLoaderName = addPlugInLoaderService ( realmServiceName , plugIns , serviceTarget , newControllers ) ; } if ( authentication != null ) { if ( authentication . hasDefined ( TRUSTSTORE ) ) { authTruststore = authentication . require ( TRUSTSTORE ) ; ServiceName ccName = addClientCertService ( realmServiceName , serviceTarget , newControllers ) ; realmBuilder . addDependency ( ccName , CallbackHandlerService . class , securityRealmService . getCallbackHandlerService ( ) . injector ( ) ) ; } if ( authentication . hasDefined ( LOCAL ) ) { ServiceName localName = addLocalService ( authentication . require ( LOCAL ) , realmServiceName , serviceTarget , newControllers ) ; realmBuilder . addDependency ( localName , CallbackHandlerService . class , securityRealmService . getCallbackHandlerService ( ) . injector ( ) ) ; } if ( authentication . hasDefined ( JAAS ) ) { authenticationName = addJaasService ( authentication . require ( JAAS ) , realmServiceName , serviceTarget , newControllers , context . isNormalServer ( ) ) ; } else if ( authentication . hasDefined ( LDAP ) ) { authenticationName = addLdapService ( authentication . require ( LDAP ) , realmServiceName , serviceTarget , newControllers ) ; } else if ( authentication . hasDefined ( ModelDescriptionConstants . PLUG_IN ) ) { authenticationName = addPlugInAuthenticationService ( authentication . require ( ModelDescriptionConstants . PLUG_IN ) , realmServiceName , plugInLoaderName , securityRealmService , serviceTarget , newControllers ) ; } else if ( authentication . hasDefined ( PROPERTIES ) ) { authenticationName = addPropertiesAuthenticationService ( authentication . require ( PROPERTIES ) , realmServiceName , realmName , serviceTarget , newControllers ) ; } else if ( authentication . hasDefined ( USERS ) ) { authenticationName = addUsersService ( context , authentication . require ( USERS ) , realmServiceName , realmName , serviceTarget , newControllers ) ; } } if ( authorization != null ) { if ( authorization . hasDefined ( PROPERTIES ) ) { authorizationName = addPropertiesAuthorizationService ( authorization . require ( PROPERTIES ) , realmServiceName , realmName , serviceTarget , newControllers ) ; } else if ( authorization . hasDefined ( ModelDescriptionConstants . PLUG_IN ) ) { authorizationName = addPlugInAuthorizationService ( authorization . require ( ModelDescriptionConstants . PLUG_IN ) , realmServiceName , plugInLoaderName , realmName , serviceTarget , newControllers ) ; } } if ( authenticationName != null ) { realmBuilder . addDependency ( authenticationName , CallbackHandlerService . class , securityRealmService . getCallbackHandlerService ( ) . injector ( ) ) ; } if ( authorizationName != null ) { realmBuilder . addDependency ( authorizationName , SubjectSupplementalService . class , securityRealmService . getSubjectSupplementalInjector ( ) ) ; } ModelNode ssl = null ; if ( serverIdentities != null ) { if ( serverIdentities . hasDefined ( SSL ) ) { ssl = serverIdentities . require ( SSL ) ; } if ( serverIdentities . hasDefined ( SECRET ) ) { ServiceName secretServiceName = addSecretService ( context , serverIdentities . require ( SECRET ) , realmServiceName , serviceTarget , newControllers ) ; realmBuilder . addDependency ( secretServiceName , CallbackHandlerFactory . class , securityRealmService . getSecretCallbackFactory ( ) ) ; } } if ( ( ssl != null ) || ( authTruststore != null ) ) { ServiceName sslServiceName = addSSLService ( context , ssl , authTruststore , realmServiceName , serviceTarget , newControllers ) ; realmBuilder . addDependency ( sslServiceName , SSLIdentityService . class , securityRealmService . getSSLIdentityInjector ( ) ) ; } <START_BUG> realmBuilder . setInitialMode ( ON_DEMAND ) ; <END_BUG> ServiceController < ? > sc = realmBuilder . install ( ) ; if ( newControllers != null ) { newControllers . add ( sc ) ; } } private ServiceName addPlugInLoaderService ( ServiceName realmServiceName , ModelNode plugInModel , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) { } private ServiceName addClientCertService ( ServiceName realmServiceName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) { } private ServiceName addJaasService ( ModelNode jaas , ServiceName realmServiceName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers , boolean injectServerManager ) { } private ServiceName addLdapService ( ModelNode ldap , ServiceName realmServiceName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) { } private ServiceName addLocalService ( ModelNode local , ServiceName realmServiceName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) { } private ServiceName addPlugInAuthenticationService ( ModelNode plugIn , ServiceName realmServiceName , ServiceName plugInLoaderName , SecurityRealmService registry , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) { } private ServiceName addPropertiesAuthenticationService ( ModelNode properties , ServiceName realmServiceName , String realmName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) { } private ServiceName addPropertiesAuthorizationService ( ModelNode properties , ServiceName realmServiceName , String realmName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) { } private ServiceName addPlugInAuthorizationService ( ModelNode properties , ServiceName realmServiceName , ServiceName plugInLoaderName , String realmName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) { } private ServiceName addSSLService ( OperationContext context , ModelNode ssl , ModelNode trustStore , ServiceName realmServiceName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) throws OperationFailedException { } private static class KeyPair { private char [ ] keystorePassword ; private char [ ] keyPassword ; } private SecurityRealmAddHandler . KeyPair addFileKeystoreService ( OperationContext context , ModelNode ssl , ServiceName serviceName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) throws OperationFailedException { } private ServiceName addSecretService ( OperationContext context , ModelNode secret , ServiceName realmServiceName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) throws OperationFailedException { } private ServiceName addUsersService ( OperationContext context , ModelNode users , ServiceName realmServiceName , String realmName , ServiceTarget serviceTarget , List < ServiceController < ? > > newControllers ) throws OperationFailedException { } private static ServiceName pathName ( String relativeTo ) { }

Fix:
realmBuilder . setInitialMode ( ACTIVE ) ;