Buggy code:
public class PersistenceUnitServiceHandler { public static final String JNDI_PROPERTY = "jboss.entity.manager.factory.jndi.name" ; private static final AttachmentKey < Map < String , PersistenceProviderAdaptor > > providerAdaptorMapKey = AttachmentKey . create ( Map . class ) ; private static final String SCOPED_UNIT_NAME = "scoped-unit-name" ; public static void deploy ( DeploymentPhaseContext phaseContext , boolean startEarly ) throws DeploymentUnitProcessingException { } public static void undeploy ( DeploymentUnit context ) { } private static void handleJarDeployment ( DeploymentPhaseContext phaseContext , boolean startEarly ) throws DeploymentUnitProcessingException { } private static void handleWarDeployment ( DeploymentPhaseContext phaseContext , boolean startEarly ) throws DeploymentUnitProcessingException { } private static void handleEarDeployment ( DeploymentPhaseContext phaseContext , boolean startEarly ) throws DeploymentUnitProcessingException { } private static void addPuService ( DeploymentPhaseContext phaseContext , ArrayList < PersistenceUnitMetadataHolder > puList , boolean startEarly ) throws DeploymentUnitProcessingException { } private static void deployPersistenceUnit ( DeploymentPhaseContext phaseContext , DeploymentUnit deploymentUnit , EEModuleDescription eeModuleDescription , Collection < ComponentDescription > components , ServiceTarget serviceTarget , ModuleClassLoader classLoader , PersistenceProviderDeploymentHolder persistenceProviderDeploymentHolder , PersistenceUnitMetadata pu , boolean startEarly ) throws DeploymentUnitProcessingException { pu . setClassLoader ( classLoader ) ; try { final HashMap < String , ValidatorFactory > properties = new HashMap < String , ValidatorFactory > ( ) ; if ( ! ( NONE . equals ( pu . getValidationMode ( ) ) ) ) { ValidatorFactory validatorFactory = SerializableValidatorFactory . validatorFactory ( ) ; properties . put ( "javax.persistence.validation.factory" , validatorFactory ) ; } final PersistenceProviderAdaptor adaptor = PersistenceUnitServiceHandler . getPersistenceProviderAdaptor ( pu , persistenceProviderDeploymentHolder , deploymentUnit ) ; PersistenceProvider provider = null ; if ( ( persistenceProviderDeploymentHolder != null ) && ( ( persistenceProviderDeploymentHolder . getProvider ( ) ) != null ) ) { List < PersistenceProvider > providerList = persistenceProviderDeploymentHolder . getProvider ( ) ; for ( PersistenceProvider persistenceProvider : providerList ) { if ( persistenceProvider . getClass ( ) . getName ( ) . equals ( pu . getPersistenceProviderClassName ( ) ) ) { provider = persistenceProvider ; JpaLogger . JPA_LOGGER . tracef ( "deployment<seq2seq4repair_space>%s<seq2seq4repair_space>is<seq2seq4repair_space>using<seq2seq4repair_space>its<seq2seq4repair_space>own<seq2seq4repair_space>copy<seq2seq4repair_space>of<seq2seq4repair_space>%s" , deploymentUnit . getName ( ) , pu . getPersistenceProviderClassName ( ) ) ; break ; } } } if ( provider == null ) { provider = PersistenceUnitServiceHandler . lookupProvider ( pu ) ; } <START_BUG> final PersistenceUnitServiceImpl service = new PersistenceUnitServiceImpl ( classLoader , pu , adaptor , provider , PersistenceUnitRegistryImpl . INSTANCE ) ; <END_BUG> deploymentUnit . addToAttachmentList ( PersistenceUnitServiceHandler . REMOVAL_KEY , new PersistenceUnitServiceHandler . PersistenceAdaptorRemoval ( pu , adaptor ) ) ; adaptor . addProviderProperties ( properties , pu ) ; final ServiceName puServiceName = PersistenceUnitServiceImpl . getPUServiceName ( pu ) ; deploymentUnit . putAttachment ( PERSISTENCE_UNIT_SERVICE_KEY , puServiceName ) ; deploymentUnit . addToAttachmentList ( DEPLOYMENT_COMPLETE_SERVICES , puServiceName ) ; PersistenceUnitServiceHandler . addPUServiceDependencyToComponents ( components , puServiceName ) ; if ( startEarly ) { phaseContext . addToAttachmentList ( NEXT_PHASE_DEPS , puServiceName ) ; } deploymentUnit . addToAttachmentList ( WEB_DEPENDENCIES , puServiceName ) ; ServiceBuilder < PersistenceUnitService > builder = serviceTarget . addService ( puServiceName , service ) ; boolean useDefaultDataSource = true ; final String jtaDataSource = PersistenceUnitServiceHandler . adjustJndi ( pu . getJtaDataSourceName ( ) ) ; final String nonJtaDataSource = PersistenceUnitServiceHandler . adjustJndi ( pu . getNonJtaDataSourceName ( ) ) ; if ( ( jtaDataSource != null ) && ( ( jtaDataSource . length ( ) ) > 0 ) ) { if ( jtaDataSource . startsWith ( "java:" ) ) { builder . addDependency ( ContextNames . bindInfoForEnvEntry ( eeModuleDescription . getApplicationName ( ) , eeModuleDescription . getModuleName ( ) , eeModuleDescription . getModuleName ( ) , false , jtaDataSource ) . getBinderServiceName ( ) , ManagedReferenceFactory . class , new PersistenceUnitServiceHandler . ManagedReferenceFactoryInjector ( service . getJtaDataSourceInjector ( ) ) ) ; useDefaultDataSource = false ; } else { builder . addDependency ( SERVICE_NAME_BASE . append ( jtaDataSource ) , new org . jboss . msc . inject . CastingInjector < DataSource > ( service . getJtaDataSourceInjector ( ) , DataSource . class ) ) ; useDefaultDataSource = false ; } } if ( ( nonJtaDataSource != null ) && ( ( nonJtaDataSource . length ( ) ) > 0 ) ) { if ( nonJtaDataSource . startsWith ( "java:" ) ) { builder . addDependency ( ContextNames . bindInfoForEnvEntry ( eeModuleDescription . getApplicationName ( ) , eeModuleDescription . getModuleName ( ) , eeModuleDescription . getModuleName ( ) , false , nonJtaDataSource ) . getBinderServiceName ( ) , ManagedReferenceFactory . class , new PersistenceUnitServiceHandler . ManagedReferenceFactoryInjector ( service . getNonJtaDataSourceInjector ( ) ) ) ; useDefaultDataSource = false ; } else { builder . addDependency ( SERVICE_NAME_BASE . append ( nonJtaDataSource ) , new org . jboss . msc . inject . CastingInjector < DataSource > ( service . getNonJtaDataSourceInjector ( ) , DataSource . class ) ) ; useDefaultDataSource = false ; } } if ( useDefaultDataSource ) { final String defaultJtaDataSource = PersistenceUnitServiceHandler . adjustJndi ( JPAService . getDefaultDataSourceName ( ) ) ; if ( ( defaultJtaDataSource != null ) && ( ( defaultJtaDataSource . length ( ) ) > 0 ) ) { builder . addDependency ( SERVICE_NAME_BASE . append ( defaultJtaDataSource ) , new org . jboss . msc . inject . CastingInjector < DataSource > ( service . getJtaDataSourceInjector ( ) , DataSource . class ) ) ; JpaLogger . JPA_LOGGER . tracef ( "%s<seq2seq4repair_space>is<seq2seq4repair_space>using<seq2seq4repair_space>the<seq2seq4repair_space>default<seq2seq4repair_space>data<seq2seq4repair_space>source<seq2seq4repair_space>'%s'" , puServiceName , defaultJtaDataSource ) ; } } adaptor . addProviderDependencies ( phaseContext . getServiceRegistry ( ) , serviceTarget , builder , pu ) ; if ( pu . getProperties ( ) . containsKey ( PersistenceUnitServiceHandler . JNDI_PROPERTY ) ) { String jndiName = pu . getProperties ( ) . get ( PersistenceUnitServiceHandler . JNDI_PROPERTY ) . toString ( ) ; final ContextNames . BindInfo bindingInfo ; if ( jndiName . startsWith ( "java:" ) ) { bindingInfo = ContextNames . bindInfoForEnvEntry ( eeModuleDescription . getApplicationName ( ) , eeModuleDescription . getModuleName ( ) , eeModuleDescription . getModuleName ( ) , false , jndiName ) ; } else { bindingInfo = ContextNames . bindInfoFor ( jndiName ) ; }

Fix:
final PersistenceUnitServiceImpl service = new PersistenceUnitServiceImpl ( classLoader , pu , adaptor , provider , PersistenceUnitRegistryImpl . INSTANCE , deploymentUnit . getServiceName ( ) ) ;