Buggy code:
public class ModuleSpecProcessor implements DeploymentUnitProcessor { private static final String DEPLOYMENT_MODULE_PREFIX = "deployment." ; public void deploy ( DeploymentPhaseContext phaseContext ) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext . getDeploymentUnit ( ) ; final DeploymentModuleLoader deploymentModuleLoader = deploymentUnit . getAttachment ( DEPLOYMENT_MODULE_LOADER ) ; if ( deploymentModuleLoader == null ) { return ; } if ( deploymentUnit . hasAttachment ( OSGI_MANIFEST ) ) { return ; } final ResourceRoot mainRoot = deploymentUnit . getAttachment ( DEPLOYMENT_ROOT ) ; if ( mainRoot == null ) { return ; } final List < ResourceRoot > additionalRoots = deploymentUnit . getAttachment ( RESOURCE_ROOTS ) ; final List < ModuleDependency > dependencies = deploymentUnit . getAttachment ( MODULE_DEPENDENCIES ) ; final ModuleIdentifier moduleIdentifier = ModuleIdentifier . create ( ( "deployment." + ( deploymentUnit . getName ( ) ) ) ) ; deploymentUnit . putAttachment ( MODULE_IDENTIFIER , moduleIdentifier ) ; final ModuleSpec . Builder specBuilder = ModuleSpec . build ( moduleIdentifier ) ; if ( ModuleRootMarker . isModuleRoot ( mainRoot ) ) { ModuleSpecProcessor . addResourceRoot ( specBuilder , mainRoot ) ; } if ( additionalRoots != null ) for ( ResourceRoot additionalRoot : additionalRoots ) { if ( ModuleRootMarker . isModuleRoot ( additionalRoot ) ) { ModuleSpecProcessor . addResourceRoot ( specBuilder , additionalRoot ) ; } } final boolean childFirst = false ; if ( childFirst ) { specBuilder . addDependency ( DependencySpec . createLocalDependencySpec ( ) ) ; } if ( dependencies != null ) for ( ModuleDependency dependency : dependencies ) { final List < FilterSpecification > importFilters = dependency . getImportFilters ( ) ; final List < FilterSpecification > exportFilters = dependency . getExportFilters ( ) ; final PathFilter importFilter ; final PathFilter exportFilter ; final MultiplePathFilterBuilder importBuilder = PathFilters . multiplePathFilterBuilder ( true ) ; for ( FilterSpecification filter : importFilters ) { importBuilder . addFilter ( filter . getPathFilter ( ) , filter . isInclude ( ) ) ; } if ( dependency . isImportServices ( ) ) { importBuilder . addFilter ( PathFilters . getMetaInfServicesFilter ( ) , true ) ; } importBuilder . addFilter ( PathFilters . getMetaInfSubdirectoriesFilter ( ) , false ) ; importBuilder . addFilter ( PathFilters . getMetaInfFilter ( ) , false ) ; importFilter = importBuilder . create ( ) ; if ( exportFilters . isEmpty ( ) ) { exportFilter = PathFilters . acceptAll ( ) ; } else { final MultiplePathFilterBuilder exportBuilder = PathFilters . multiplePathFilterBuilder ( dependency . isExport ( ) ) ; for ( FilterSpecification filter : exportFilters ) { exportBuilder . addFilter ( filter . getPathFilter ( ) , filter . isInclude ( ) ) ; } exportFilter = exportBuilder . create ( ) ; } DependencySpec depSpec = DependencySpec . createModuleDependencySpec ( importFilter , exportFilter , dependency . getModuleLoader ( ) , dependency . getIdentifier ( ) , dependency . isOptional ( ) ) ; specBuilder . addDependency ( depSpec ) ; final String depName = dependency . getIdentifier ( ) . getName ( ) ; if ( depName . startsWith ( ModuleSpecProcessor . DEPLOYMENT_MODULE_PREFIX ) ) { final String depDeploymentName = depName . substring ( ModuleSpecProcessor . DEPLOYMENT_MODULE_PREFIX . length ( ) ) ; <START_BUG> phaseContext . addToAttachmentList ( NEXT_PHASE_DEPS , JBOSS_DEPLOYMENT_UNIT . append ( depDeploymentName ) . append ( CONFIGURE_MODULE . name ( ) ) ) ; <END_BUG> } } if ( ! childFirst ) { specBuilder . addDependency ( DependencySpec . createLocalDependencySpec ( ) ) ; } final ModuleSpec moduleSpec = specBuilder . create ( ) ; deploymentModuleLoader . addModuleSpec ( moduleSpec ) ; } private static void addResourceRoot ( final ModuleSpec . Builder specBuilder , final ResourceRoot resource ) throws DeploymentUnitProcessingException { } public void undeploy ( DeploymentUnit context ) { } }

Fix:
phaseContext . addToAttachmentList ( NEXT_PHASE_DEPS , Services . deploymentUnitName ( depDeploymentName , CONFIGURE_MODULE ) ) ;