Buggy code:
public class RaXmlDeploymentProcessor implements DeploymentUnitProcessor { private final MetadataRepository mdr ; public RaXmlDeploymentProcessor ( final MetadataRepository mdr ) { } public void deploy ( DeploymentPhaseContext phaseContext ) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext . getDeploymentUnit ( ) ; final ManagementResourceRegistration registration = deploymentUnit . getAttachment ( MUTABLE_REGISTRATION_ATTACHMENT ) ; final ConnectorXmlDescriptor connectorXmlDescriptor = deploymentUnit . getAttachment ( ATTACHMENT_KEY ) ; if ( connectorXmlDescriptor == null ) { return ; } ResourceAdapters raxmls = null ; final ServiceController < ? > raService = phaseContext . getServiceRegistry ( ) . getService ( RESOURCEADAPTERS_SERVICE ) ; if ( raService != null ) raxmls = ( ( ResourceAdapters ) ( raService . getValue ( ) ) ) ; if ( raxmls == null ) return ; ConnectorLogger . ROOT_LOGGER . tracef ( "processing<seq2seq4repair_space>Raxml" ) ; Module module = deploymentUnit . getAttachment ( MODULE ) ; if ( module == null ) throw ConnectorMessages . MESSAGES . failedToGetModuleAttachment ( deploymentUnit ) ; try { final ServiceTarget serviceTarget = phaseContext . getServiceTarget ( ) ; for ( ResourceAdapter raxml : raxmls . getResourceAdapters ( ) ) { String deploymentUnitPrefix = "" ; if ( ( deploymentUnit . getParent ( ) ) != null ) { deploymentUnitPrefix = ( deploymentUnit . getParent ( ) . getName ( ) ) + "#" ; } String deploymentUnitName = deploymentUnitPrefix + ( deploymentUnit . getName ( ) ) ; if ( deploymentUnitName . equals ( raxml . getArchive ( ) ) ) { final String deployment ; if ( ( deploymentUnitName . lastIndexOf ( '.' ) ) == ( - 1 ) ) { deployment = deploymentUnitName ; } else { deployment = deploymentUnitName . substring ( 0 , deploymentUnitName . lastIndexOf ( '.' ) ) ; } String raName = connectorXmlDescriptor . getDeploymentName ( ) ; ServiceName serviceName = ConnectorServices . registerDeployment ( raName ) ; ResourceAdapterXmlDeploymentService service = new ResourceAdapterXmlDeploymentService ( connectorXmlDescriptor , raxml , module , deployment , serviceName ) ; ServiceBuilder builder = serviceTarget . addService ( serviceName , service ) . addDependency ( IRONJACAMAR_MDR , MetadataRepository . class , service . getMdrInjector ( ) ) . addDependency ( RA_REPOSISTORY_SERVICE , ResourceAdapterRepository . class , service . getRaRepositoryInjector ( ) ) . addDependency ( MANAGEMENT_REPOSISTORY_SERVICE , ManagementRepository . class , service . getManagementRepositoryInjector ( ) ) . addDependency ( RESOURCE_ADAPTER_REGISTRY_SERVICE , ResourceAdapterDeploymentRegistry . class , service . getRegistryInjector ( ) ) . addDependency ( TRANSACTION_INTEGRATION_SERVICE , TransactionIntegration . class , service . getTxIntegrationInjector ( ) ) . addDependency ( CONNECTOR_CONFIG_SERVICE , JcaSubsystemConfiguration . class , service . getConfigInjector ( ) ) . addDependency ( SERVICE_NAME , SubjectFactory . class , service . getSubjectFactoryInjector ( ) ) . addDependency ( CCM_SERVICE , CachedConnectionManager . class , service . getCcmInjector ( ) ) . addDependency ( IDLE_REMOVER_SERVICE ) . addDependency ( CONNECTION_VALIDATOR_SERVICE ) . addDependency ( NamingService . SERVICE_NAME ) . addDependency ( RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX . append ( connectorXmlDescriptor . getDeploymentName ( ) ) ) ; 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 : { <START_BUG> CommonDeployment deploymentMD = ( ( org . jboss . as . connector . metadata . deployment . ResourceAdapterDeploymentService ) ( controller . getService ( ) ) ) . getRaDeployment ( ) ; <END_BUG> if ( ( ( deploymentMD . getConnectionManagers ( ) ) != null ) && ( ( deploymentMD . getConnectionManagers ( ) [ 0 ] . getPool ( ) ) != null ) ) { StatisticsPlugin poolStats = deploymentMD . getConnectionManagers ( ) [ 0 ] . 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 ) ; ManagementResourceRegistration subRegistration = registration . registerSubModel ( pe , statsResourceDescriptionProvider ) ; for ( String statName : poolStats . getNames ( ) ) { subRegistration . registerMetric ( statName , new org . jboss . as . connector . pool . PoolMetrics . ParametrizedPoolMetricsHandler ( poolStats ) ) ; } subRegistration . 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 ) ; if ( ( registration . getSubModel ( PathAddress . pathAddress ( pe ) ) ) != null ) { registration . unregisterSubModel ( pe ) ; } break ; } } } } ) ; builder . setInitialMode ( ACTIVE ) . install ( ) ; } } } catch ( Throwable t ) { throw new DeploymentUnitProcessingException ( t ) ; } } public void undeploy ( final DeploymentUnit context ) { } }

Fix:
CommonDeployment deploymentMD = ( ( ResourceAdapterXmlDeploymentService ) ( controller . getService ( ) ) ) . getRaxmlDeployment ( ) ;