Buggy code:
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 > ( ) ; getJpaDependencies ( deploymentUnit , jpaServices ) ; for ( DeploymentUnit subDeployment : subDeployments ) { getJpaDependencies ( deploymentUnit , jpaServices ) ; 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 ) ; final ResourceRoot subDeploymentRoot = subDeployment . getAttachment ( DEPLOYMENT_ROOT ) ; final EjbInjectionServices ejbInjectionServices = new org . jboss . as . weld . services . bootstrap . WeldEjbInjectionServices ( deploymentUnit . getServiceRegistry ( ) , eeModuleDescription , eeApplicationDescription , subDeploymentRoot . getRoot ( ) ) ; bdm . addService ( EjbInjectionServices . class , ejbInjectionServices ) ; final ResourceInjectionServices resourceInjectionServices = new org . jboss . as . weld . services . bootstrap . WeldResourceInjectionServices ( deploymentUnit . getServiceRegistry ( ) , eeModuleDescription ) ; bdm . addService ( ResourceInjectionServices . class , resourceInjectionServices ) ; } for ( Map . Entry < ModuleIdentifier , BeanDeploymentModule > entry : bdmsByIdentifier . entrySet ( ) ) { final ModuleSpecification bdmSpec = moduleSpecByIdentifier . get ( entry . getKey ( ) ) ; final BeanDeploymentModule bdm = entry . getValue ( ) ; if ( bdm == rootBeanDeploymentModule ) { continue ; } for ( ModuleDependency dependency : bdmSpec . getSystemDependencies ( ) ) { BeanDeploymentModule other = bdmsByIdentifier . get ( dependency . getIdentifier ( ) ) ; if ( ( other != null ) && ( other != bdm ) ) { bdm . addBeanDeploymentModule ( other ) ; } } } final EjbInjectionServices ejbInjectionServices = new org . jboss . as . weld . services . bootstrap . WeldEjbInjectionServices ( deploymentUnit . getServiceRegistry ( ) , eeModuleDescription , eeApplicationDescription , deploymentRoot . getRoot ( ) ) ; final ResourceInjectionServices resourceInjectionServices = new org . jboss . as . weld . services . bootstrap . WeldResourceInjectionServices ( deploymentUnit . getServiceRegistry ( ) , eeModuleDescription ) ; rootBeanDeploymentModule . addService ( EjbInjectionServices . class , ejbInjectionServices ) ; rootBeanDeploymentModule . addService ( ResourceInjectionServices . class , resourceInjectionServices ) ; for ( final BeanDeploymentArchiveImpl additional : deploymentUnit . getAttachmentList ( ADDITIONAL_BEAN_DEPLOYMENT_MODULES ) ) { beanDeploymentArchives . add ( additional ) ; additional . getServices ( ) . add ( EjbInjectionServices . class , ejbInjectionServices ) ; additional . getServices ( ) . add ( ResourceInjectionServices . class , resourceInjectionServices ) ; } final Collection < Metadata < Extension > > extensions = WeldPortableExtensions . getPortableExtensions ( deploymentUnit ) . getExtensions ( ) ; <START_BUG> final WeldDeployment deployment = new WeldDeployment ( beanDeploymentArchives , extensions , module , subDeploymentLoaders , deploymentUnit ) ; <END_BUG> final WeldBootstrapService weldBootstrapService = new WeldBootstrapService ( deployment , Environments . EE_INJECT , deploymentUnit . getName ( ) ) ; installBootstrapConfigurationService ( deployment , parent ) ; weldBootstrapService . addWeldService ( EjbInjectionServices . class , ejbInjectionServices ) ; weldBootstrapService . addWeldService ( ResourceInjectionServices . class , resourceInjectionServices ) ; weldBootstrapService . 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 ) ; final JaxwsInjectionServices rootJaxWsInjectionServices = new org . jboss . as . weld . services . bootstrap . WeldJaxwsInjectionServices ( deploymentUnit ) ; weldBootstrapService . addWeldService ( JpaInjectionServices . class , rootJpaInjectionServices ) ; weldBootstrapService . addWeldService ( JaxwsInjectionServices . class , rootJaxWsInjectionServices ) ; final ServiceBuilder < WeldBootstrapService > weldBootstrapServiceBuilder = serviceTarget . addService ( weldBootstrapServiceName , weldBootstrapService ) ; weldBootstrapServiceBuilder . addDependencies ( TCCLSingletonService . SERVICE_NAME ) ; installSecurityService ( serviceTarget , deploymentUnit , weldBootstrapService , weldBootstrapServiceBuilder ) ; installTransactionService ( serviceTarget , deploymentUnit , weldBootstrapService , weldBootstrapServiceBuilder ) ; weldBootstrapServiceBuilder . install ( ) ; final List < SetupAction > setupActions = new ArrayList < SetupAction > ( ) ; JavaNamespaceSetup naming = deploymentUnit . getAttachment ( JAVA_NAMESPACE_SETUP_ACTION ) ; if ( naming != null ) { setupActions . add ( naming ) ; } final WeldStartService weldStartService = new WeldStartService ( setupActions , module . getClassLoader ( ) , Utils . getRootDeploymentUnit ( deploymentUnit ) . getServiceName ( ) ) ; ServiceBuilder < WeldStartService > startService = serviceTarget . addService ( deploymentUnit . getServiceName ( ) . append ( WeldStartService . SERVICE_NAME ) , weldStartService ) . addDependency ( weldBootstrapServiceName , WeldBootstrapService . class , weldStartService . getBootstrap ( ) ) . addDependencies ( jpaServices ) ; startService . addDependency ( JndiNamingDependencyProcessor . serviceName ( deploymentUnit ) ) ; final EarMetaData earConfig = deploymentUnit . getAttachment ( EAR_METADATA ) ; if ( ( earConfig == null ) || ( ! ( earConfig . getInitializeInOrder ( ) ) ) ) { for ( DeploymentUnit sub : subDeployments ) { startService . addDependency ( JndiNamingDependencyProcessor . serviceName ( sub ) ) ;

Fix:
final WeldDeployment deployment = new WeldDeployment ( beanDeploymentArchives , extensions , module , subDeploymentLoaders , deploymentUnit , rootBeanDeploymentModule ) ;