Buggy code:
public class ParsedRaDeploymentProcessor implements DeploymentUnitProcessor { public ParsedRaDeploymentProcessor ( ) { } public void deploy ( DeploymentPhaseContext phaseContext ) throws DeploymentUnitProcessingException { final ConnectorXmlDescriptor connectorXmlDescriptor = phaseContext . getDeploymentUnit ( ) . getAttachment ( ATTACHMENT_KEY ) ; final ManagementResourceRegistration registration = phaseContext . getDeploymentUnit ( ) . getAttachment ( MUTABLE_REGISTRATION_ATTACHMENT ) ; if ( connectorXmlDescriptor == null ) { return ; } final DeploymentUnit deploymentUnit = phaseContext . getDeploymentUnit ( ) ; final IronJacamarXmlDescriptor ironJacamarXmlDescriptor = deploymentUnit . getAttachment ( IronJacamarXmlDescriptor . ATTACHMENT_KEY ) ; final Module module = deploymentUnit . getAttachment ( MODULE ) ; if ( module == null ) throw ConnectorMessages . MESSAGES . failedToGetModuleAttachment ( phaseContext . getDeploymentUnit ( ) ) ; final ClassLoader classLoader = module . getClassLoader ( ) ; Connector cmd = ( connectorXmlDescriptor != null ) ? connectorXmlDescriptor . getConnector ( ) : null ; final IronJacamar ijmd = ( ironJacamarXmlDescriptor != null ) ? ironJacamarXmlDescriptor . getIronJacamar ( ) : null ; try { Annotations annotator = new Annotations ( ) ; Map < ResourceRoot , Index > indexes = AnnotationIndexUtils . getAnnotationIndexes ( deploymentUnit ) ; for ( Map . Entry < ResourceRoot , Index > entry : indexes . entrySet ( ) ) { AnnotationRepository repository = new org . jboss . as . connector . annotations . repository . jandex . JandexAnnotationRepositoryImpl ( entry . getValue ( ) , classLoader ) ; cmd = annotator . merge ( cmd , repository , classLoader ) ; } if ( cmd != null ) { cmd . validate ( ) ; cmd = new Merger ( ) . mergeConnectorWithCommonIronJacamar ( ijmd , cmd ) ; } final ServiceName deployerServiceName = RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX . append ( connectorXmlDescriptor . getDeploymentName ( ) ) ; final ResourceAdapterDeploymentService raDeploymentService = new ResourceAdapterDeploymentService ( connectorXmlDescriptor , cmd , ijmd , module , null ) ; final ServiceTarget serviceTarget = phaseContext . getServiceTarget ( ) ; ServiceBuilder builder = serviceTarget . addService ( deployerServiceName , raDeploymentService ) . addDependency ( IRONJACAMAR_MDR , MetadataRepository . class , raDeploymentService . getMdrInjector ( ) ) . addDependency ( RA_REPOSITORY_SERVICE , ResourceAdapterRepository . class , raDeploymentService . getRaRepositoryInjector ( ) ) . addDependency ( MANAGEMENT_REPOSITORY_SERVICE , ManagementRepository . class , raDeploymentService . getManagementRepositoryInjector ( ) ) . addDependency ( RESOURCE_ADAPTER_REGISTRY_SERVICE , ResourceAdapterDeploymentRegistry . class , raDeploymentService . getRegistryInjector ( ) ) . addDependency ( TRANSACTION_INTEGRATION_SERVICE , TransactionIntegration . class , raDeploymentService . getTxIntegrationInjector ( ) ) . addDependency ( CONNECTOR_CONFIG_SERVICE , JcaSubsystemConfiguration . class , raDeploymentService . getConfigInjector ( ) ) . addDependency ( SERVICE_NAME , SubjectFactory . class , raDeploymentService . getSubjectFactoryInjector ( ) ) . addDependency ( CCM_SERVICE , CachedConnectionManager . class , raDeploymentService . getCcmInjector ( ) ) . addDependency ( IDLE_REMOVER_SERVICE ) . addDependency ( CONNECTION_VALIDATOR_SERVICE ) . addDependency ( NamingService . SERVICE_NAME ) ; builder . addListener ( new org . jboss . msc . service . AbstractServiceListener < Object > ( ) { public void transition ( final ServiceController < ? extends Object > controller , final ServiceController . Transition transition ) { switch ( transition ) { case STARTING_to_UP : { CommonDeployment deploymentMD = ( ( ResourceAdapterDeploymentService ) ( controller . getService ( ) ) ) . getRaDeployment ( ) ; if ( ( deploymentMD . getConnectionManagers ( ) ) != null ) { for ( ConnectionManager cm : deploymentMD . getConnectionManagers ( ) ) { if ( ( cm . getPool ( ) ) != null ) { StatisticsPlugin poolStats = cm . getPool ( ) . getStatistics ( ) ; if ( ( poolStats . getNames ( ) . size ( ) ) != 0 ) { DescriptionProvider statsResourceDescriptionProvider = new org . jboss . as . connector . StatisticsDescriptionProvider ( ResourceAdaptersSubsystemProviders . RESOURCE_NAME , "statistics" , poolStats ) ; PathElement pe = PathElement . pathElement ( SUBSYSTEM , SUBSYSTEM_NAME ) ; PathElement peCD = PathElement . pathElement ( CONNECTIONDEFINITIONS_NAME , cm . getJndiName ( ) ) ; ManagementResourceRegistration overrideRegistration = registration ; if ( registration . isAllowsOverride ( ) ) { overrideRegistration = registration . registerOverrideModel ( deploymentUnit . getName ( ) , new OverrideDescriptionProvider ( ) { @ Override public Map < String , ModelNode > getAttributeOverrideDescriptions ( Locale locale ) { return Collections . emptyMap ( ) ; } @ Override public Map < String , ModelNode > getChildTypeOverrideDescriptions ( Locale locale ) { return Collections . emptyMap ( ) ; } } ) ; } ManagementResourceRegistration subRegistration = overrideRegistration . getSubModel ( PathAddress . pathAddress ( pe ) ) ; if ( subRegistration == null ) { subRegistration = overrideRegistration . registerSubModel ( pe , new org . jboss . as . connector . SubSystemExtensionDescriptionProvider ( ResourceAdaptersSubsystemProviders . RESOURCE_NAME , "statistics" ) ) ; } if ( ( subRegistration . getSubModel ( PathAddress . pathAddress ( peCD ) ) ) == null ) { <START_BUG> ManagementResourceRegistration cdSubRegistration = subRegistration . registerSubModel ( pe , statsResourceDescriptionProvider ) ; <END_BUG> for ( String statName : poolStats . getNames ( ) ) { cdSubRegistration . registerMetric ( statName , new org . jboss . as . connector . pool . PoolMetrics . ParametrizedPoolMetricsHandler ( poolStats ) ) ; } cdSubRegistration . registerOperationHandler ( "clear-statistics" , new org . jboss . as . connector . subsystems . ClearStatisticsHandler ( poolStats ) , CLEAR_STATISTICS_DESC , false ) ; } } } } } break ; } case UP_to_STOP_REQUESTED : { PathElement pe = PathElement . pathElement ( SUBSYSTEM , SUBSYSTEM_NAME ) ; ManagementResourceRegistration overrideRegistration = registration . getOverrideModel ( deploymentUnit . getName ( ) ) ; if ( ( overrideRegistration . getSubModel ( PathAddress . pathAddress ( pe ) ) ) != null ) { overrideRegistration . unregisterSubModel ( pe ) ; } break ; } } } } ) ; builder . setInitialMode ( ACTIVE ) . install ( ) ; } catch ( Throwable t ) { throw new DeploymentUnitProcessingException ( t ) ; } } public void undeploy ( final DeploymentUnit context ) { } }

Fix:
ManagementResourceRegistration cdSubRegistration = subRegistration . registerSubModel ( peCD , statsResourceDescriptionProvider ) ;