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 ServiceTarget serviceTarget = phaseContext . getServiceTarget ( ) ; if ( ! ( WeldDeploymentMarker . isWeldDeployment ( deploymentUnit ) ) ) { return ; } 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 List < BeanDeploymentArchiveImpl > beanDeploymentArchives = deploymentUnit . getAttachment ( ATTACHMENT_KEY ) ; for ( BeanDeploymentArchiveImpl bda : beanDeploymentArchives ) { bda . addBeanDeploymentArchives ( beanDeploymentArchives ) ; } final ServiceLoader < Extension > loader = ServiceLoader . load ( Extension . class , module . getClassLoader ( ) ) ; final HashSet < Metadata < Extension > > extensions = new HashSet < Metadata < Extension > > ( ) ; final Iterator < Metadata < Extension > > iterator = loader . iterator ( ) ; while ( iterator . hasNext ( ) ) { Metadata < Extension > extension = iterator . next ( ) ; extensions . add ( extension ) ; } final WeldDeployment deployment = new WeldDeployment ( new HashSet < BeanDeploymentArchiveImpl > ( beanDeploymentArchives ) , extensions , module ) ; final WeldContainer weldContainer = new WeldContainer ( deployment , Environments . EE_INJECT ) ; final WeldService weldService = new WeldService ( weldContainer ) ; final ServiceName weldServiceName = deploymentUnit . getServiceName ( ) . append ( SERVICE_NAME ) ; final ServiceBuilder < WeldContainer > weldServiceBuilder = serviceTarget . addService ( weldServiceName , weldService ) ; installEjbInjectionService ( serviceTarget , deploymentUnit , weldService , weldServiceBuilder ) ; installEjbService ( serviceTarget , deploymentUnit , weldService , weldServiceBuilder ) ; installJpaInjectionService ( serviceTarget , deploymentUnit , weldService , weldServiceBuilder ) ; installResourceInjectionService ( serviceTarget , deploymentUnit , weldService , weldServiceBuilder ) ; installSecurityService ( serviceTarget , deploymentUnit , weldService , weldServiceBuilder ) ; installTransactionService ( serviceTarget , deploymentUnit , weldService , weldServiceBuilder ) ; installValidationService ( serviceTarget , deploymentUnit , weldService , weldServiceBuilder ) ; weldServiceBuilder . install ( ) ; final ServiceName beanManagerServiceName = deploymentUnit . getServiceName ( ) . append ( NAME ) ; <START_BUG> BeanManagerService beanManagerService = new BeanManagerService ( deployment . getAdditionalBeanDeploymentArchive ( ) . getId ( ) ) ; <END_BUG> serviceTarget . addService ( beanManagerServiceName , beanManagerService ) . addDependency ( weldServiceName , WeldContainer . class , beanManagerService . getWeldContainer ( ) ) . install ( ) ; final ServiceName moduleContextServiceName = ContextServiceNameBuilder . module ( deploymentUnit ) ; final ServiceName beanManagerBindingServiceName = moduleContextServiceName . append ( "BeanManager" ) ; InjectedValue < BeanManager > injectedBeanManager = new InjectedValue < BeanManager > ( ) ; BinderService < BeanManager > beanManagerBindingService = new BinderService < BeanManager > ( "BeanManager" , injectedBeanManager ) ; serviceTarget . addService ( beanManagerBindingServiceName , beanManagerBindingService ) . addDependency ( moduleContextServiceName , Context . class , beanManagerBindingService . getContextInjector ( ) ) . addDependency ( beanManagerServiceName , BeanManager . class , injectedBeanManager ) . install ( ) ; } private ServiceName installEjbInjectionService ( ServiceTarget serviceTarget , DeploymentUnit deploymentUnit , WeldService weldService , ServiceBuilder < WeldContainer > weldServiceBuilder ) { } private ServiceName installEjbService ( ServiceTarget serviceTarget , DeploymentUnit deploymentUnit , WeldService weldService , ServiceBuilder < WeldContainer > weldServiceBuilder ) { } private ServiceName installJpaInjectionService ( ServiceTarget serviceTarget , DeploymentUnit deploymentUnit , WeldService weldService , ServiceBuilder < WeldContainer > weldServiceBuilder ) { } 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 ) { } private ServiceName installValidationService ( ServiceTarget serviceTarget , DeploymentUnit deploymentUnit , WeldService weldService , ServiceBuilder < WeldContainer > weldServiceBuilder ) { } @ Override public void undeploy ( DeploymentUnit context ) { } }

Fix:
BeanManagerService beanManagerService = new BeanManagerService ( deployment . getTopLevelBeanDeploymentArchive ( ) . getId ( ) ) ;