Buggy code:
public class WeldDeploymentProcessor implements DeploymentUnitProcessor { private static final Logger log = Logger . getLogger ( "org.jboss.weld" ) ; @ Override public void deploy ( DeploymentPhaseContext phaseContext ) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext . getDeploymentUnit ( ) ; final DeploymentUnit parent = ( ( deploymentUnit . getParent ( ) ) == null ) ? deploymentUnit : deploymentUnit . getParent ( ) ; final ServiceTarget serviceTarget = phaseContext . getServiceTarget ( ) ; final ResourceRoot deploymentRoot = deploymentUnit . getAttachment ( DEPLOYMENT_ROOT ) ; if ( ! ( WeldDeploymentMarker . isPartOfWeldDeployment ( deploymentUnit ) ) ) { return ; } final ServiceName weldServiceName = parent . getServiceName ( ) . append ( SERVICE_NAME ) ; deploymentUnit . addToAttachmentList ( WEB_DEPENDENCIES , weldServiceName ) ; if ( ( deploymentUnit . getParent ( ) ) != null ) { return ; } WeldDeploymentProcessor . log . info ( ( "Starting<seq2seq4repair_space>Services<seq2seq4repair_space>for<seq2seq4repair_space>CDI<seq2seq4repair_space>deployment:<seq2seq4repair_space>" + ( phaseContext . getDeploymentUnit ( ) . getName ( ) ) ) ) ; final Module module = deploymentUnit . getAttachment ( MODULE ) ; final ModuleSpecification moduleSpecification = deploymentUnit . getAttachment ( MODULE_SPECIFICATION ) ; final Set < BeanDeploymentArchiveImpl > beanDeploymentArchives = new HashSet < BeanDeploymentArchiveImpl > ( ) ; final Map < ModuleIdentifier , BeanDeploymentModule > bdmsByIdentifier = new HashMap < ModuleIdentifier , BeanDeploymentModule > ( ) ; final Map < ModuleIdentifier , ModuleSpecification > moduleSpecByIdentifier = new HashMap < ModuleIdentifier , ModuleSpecification > ( ) ; final BeanDeploymentModule rootBeanDeploymentModule = deploymentUnit . getAttachment ( BEAN_DEPLOYMENT_MODULE ) ; final EEModuleDescription eeModuleDescription = deploymentUnit . getAttachment ( EE_MODULE_DESCRIPTION ) ; final EEApplicationDescription eeApplicationDescription = deploymentUnit . getAttachment ( EE_APPLICATION_DESCRIPTION ) ; bdmsByIdentifier . put ( module . getIdentifier ( ) , rootBeanDeploymentModule ) ; moduleSpecByIdentifier . put ( module . getIdentifier ( ) , moduleSpecification ) ; beanDeploymentArchives . addAll ( rootBeanDeploymentModule . getBeanDeploymentArchives ( ) ) ; final List < DeploymentUnit > subDeployments = deploymentUnit . getAttachmentList ( SUB_DEPLOYMENTS ) ; final Set < ClassLoader > subDeploymentLoaders = new HashSet < ClassLoader > ( ) ; for ( DeploymentUnit subDeployment : subDeployments ) { final Module subDeploymentModule = subDeployment . getAttachment ( MODULE ) ; if ( subDeploymentModule == null ) { continue ; } subDeploymentLoaders . add ( subDeploymentModule . getClassLoader ( ) ) ; final ModuleSpecification subDeploymentModuleSpec = subDeployment . getAttachment ( MODULE_SPECIFICATION ) ; final BeanDeploymentModule bdm = subDeployment . getAttachment ( BEAN_DEPLOYMENT_MODULE ) ; if ( bdm == null ) { continue ; } beanDeploymentArchives . addAll ( bdm . getBeanDeploymentArchives ( ) ) ; bdmsByIdentifier . put ( subDeploymentModule . getIdentifier ( ) , bdm ) ; moduleSpecByIdentifier . put ( subDeploymentModule . getIdentifier ( ) , subDeploymentModuleSpec ) ; } for ( Map . Entry < ModuleIdentifier , BeanDeploymentModule > entry : bdmsByIdentifier . entrySet ( ) ) { final ModuleSpecification bdmSpec = moduleSpecByIdentifier . get ( entry . getKey ( ) ) ; final BeanDeploymentModule bdm = entry . getValue ( ) ; if ( bdm == rootBeanDeploymentModule ) { continue ; } <START_BUG> for ( ModuleDependency dependency : bdmSpec . getDependencies ( ) ) { <END_BUG> BeanDeploymentModule other = bdmsByIdentifier . get ( dependency . getIdentifier ( ) ) ; if ( ( other != null ) && ( other != bdm ) ) { bdm . addBeanDeploymentModule ( other ) ; } } } final List < Metadata < Extension > > extensions = deploymentUnit . getAttachmentList ( PORTABLE_EXTENSIONS ) ; final WeldDeployment deployment = new WeldDeployment ( beanDeploymentArchives , extensions , module , subDeploymentLoaders ) ; final WeldContainer weldContainer = new WeldContainer ( deployment , Environments . EE_INJECT ) ; final ValidatorFactory factory = deploymentUnit . getAttachment ( VALIDATOR_FACTORY ) ; weldContainer . addWeldService ( ValidationServices . class , new org . jboss . as . weld . services . bootstrap . WeldValidationServices ( factory ) ) ; final EjbInjectionServices ejbInjectionServices = new org . jboss . as . weld . services . bootstrap . WeldEjbInjectionServices ( deploymentUnit . getServiceRegistry ( ) , eeModuleDescription , eeApplicationDescription , deploymentRoot . getRoot ( ) ) ; weldContainer . addWeldService ( EjbInjectionServices . class , ejbInjectionServices ) ; weldContainer . addWeldService ( EjbServices . class , new org . jboss . as . weld . services . bootstrap . WeldEjbServices ( deploymentUnit . getServiceRegistry ( ) ) ) ; final JpaInjectionServices rootJpaInjectionServices = new org . jboss . as . weld . services . bootstrap . WeldJpaInjectionServices ( deploymentUnit , deploymentUnit . getServiceRegistry ( ) ) ; weldContainer . addWeldService ( JpaInjectionServices . class , rootJpaInjectionServices ) ; final WeldService weldService = new WeldService ( weldContainer ) ; final ServiceBuilder < WeldContainer > weldServiceBuilder = serviceTarget . addService ( weldServiceName , weldService ) ; weldServiceBuilder . addDependencies ( TCCLSingletonService . SERVICE_NAME ) ; installResourceInjectionService ( serviceTarget , deploymentUnit , weldService , weldServiceBuilder ) ; installSecurityService ( serviceTarget , deploymentUnit , weldService , weldServiceBuilder ) ; installTransactionService ( serviceTarget , deploymentUnit , weldService , weldServiceBuilder ) ; weldServiceBuilder . install ( ) ; } private ServiceName installSecurityService ( ServiceTarget serviceTarget , DeploymentUnit deploymentUnit , WeldService weldService , ServiceBuilder < WeldContainer > weldServiceBuilder ) { } private ServiceName installResourceInjectionService ( ServiceTarget serviceTarget , DeploymentUnit deploymentUnit , WeldService weldService , ServiceBuilder < WeldContainer > weldServiceBuilder ) { } private ServiceName installTransactionService ( final ServiceTarget serviceTarget , final DeploymentUnit deploymentUnit , WeldService weldService , ServiceBuilder < WeldContainer > weldServiceBuilder ) { } @ Override public void undeploy ( DeploymentUnit context ) { } }

Fix:
for ( ModuleDependency dependency : bdmSpec . getSystemDependencies ( ) ) {