Buggy code:
protected void processDeployment ( final String hostName , final WarMetaData warMetaData , final DeploymentUnit deploymentUnit , final ServiceTarget serviceTarget ) throws DeploymentUnitProcessingException { final VirtualFile deploymentRoot = deploymentUnit . getAttachment ( DEPLOYMENT_ROOT ) . getRoot ( ) ; final Module module = deploymentUnit . getAttachment ( MODULE ) ; if ( module == null ) { throw new DeploymentUnitProcessingException ( ( "failed<seq2seq4repair_space>to<seq2seq4repair_space>resolve<seq2seq4repair_space>module<seq2seq4repair_space>for<seq2seq4repair_space>deployment<seq2seq4repair_space>" + deploymentRoot ) ) ; } final ClassLoader classLoader = module . getClassLoader ( ) ; final JBossWebMetaData metaData = warMetaData . getMergedJBossWebMetaData ( ) ; final EEModuleDescription moduleDescription = deploymentUnit . getAttachment ( EE_MODULE_DESCRIPTION ) ; final StandardContext webContext = new StandardContext ( ) ; final ContextConfig config = new JBossContextConfig ( deploymentUnit ) ; List < ValveMetaData > valves = metaData . getValves ( ) ; if ( valves == null ) { metaData . setValves ( ( valves = new ArrayList < ValveMetaData > ( ) ) ) ; } final ValveMetaData valve = new ValveMetaData ( ) ; valve . setModule ( "org.jboss.as.web" ) ; valve . setValveClass ( NamingValve . class . getName ( ) ) ; valve . setId ( NamingValve . class . getName ( ) ) ; valves . add ( valve ) ; try { webContext . setDocBase ( deploymentRoot . getPhysicalFile ( ) . getAbsolutePath ( ) ) ; } catch ( IOException e ) { throw new DeploymentUnitProcessingException ( e ) ; } webContext . addLifecycleListener ( config ) ; String pathName ; if ( ( metaData . getContextRoot ( ) ) == null ) { pathName = "//" + ( deploymentUnit . getName ( ) . substring ( 0 , ( ( deploymentUnit . getName ( ) . length ( ) ) - 4 ) ) ) ; } else { pathName = metaData . getContextRoot ( ) ; if ( "//" . equals ( pathName ) ) { pathName = "" ; } else if ( ( ( pathName . length ( ) ) > 0 ) && ( ( pathName . charAt ( 0 ) ) != '//' ) ) { pathName = "//" + pathName ; } } webContext . setPath ( pathName ) ; webContext . setIgnoreAnnotations ( true ) ; webContext . setCrossContext ( ( ! ( metaData . isDisableCrossContext ( ) ) ) ) ; final WebInjectionContainer injectionContainer = new WebInjectionContainer ( module . getClassLoader ( ) ) ; final Map < String , ComponentInstantiator > components = deploymentUnit . getAttachment ( WEB_COMPONENT_INSTANTIATORS ) ; if ( components != null ) { for ( Map . Entry < String , ComponentInstantiator > entry : components . entrySet ( ) ) { injectionContainer . addInstantiator ( entry . getKey ( ) , entry . getValue ( ) ) ; } } webContext . setInstanceManager ( injectionContainer ) ; final Loader loader = new WebCtxLoader ( classLoader ) ; webContext . setLoader ( loader ) ; switch ( metaData . getSessionCookies ( ) ) { case JBossWebMetaData . SESSION_COOKIES_ENABLED : webContext . setCookies ( true ) ; break ; case JBossWebMetaData . SESSION_COOKIES_DISABLED : webContext . setCookies ( false ) ; break ; } String metaDataSecurityDomain = metaData . getSecurityDomain ( ) ; if ( metaDataSecurityDomain != null ) { metaDataSecurityDomain = metaDataSecurityDomain . trim ( ) ; } String securityDomain = ( metaDataSecurityDomain == null ) ? SecurityConstants . DEFAULT_APPLICATION_POLICY : SecurityUtil . unprefixSecurityDomain ( metaDataSecurityDomain ) ; Map < String , Set < String > > principalVersusRolesMap = metaData . getSecurityRoles ( ) . getPrincipalVersusRolesMap ( ) ; final List < ServletContextAttribute > attributes = deploymentUnit . getAttachment ( ATTACHMENT_KEY ) ; if ( attributes != null ) { final ServletContext context = webContext . getServletContext ( ) ; for ( ServletContextAttribute attribute : attributes ) { context . setAttribute ( attribute . getName ( ) , attribute . getValue ( ) ) ; } } try { final ServiceName deploymentServiceName = WebSubsystemServices . deploymentServiceName ( hostName , pathName ) ; final ServiceName realmServiceName = deploymentServiceName . append ( "realm" ) ; final JBossWebRealmService realmService = new JBossWebRealmService ( principalVersusRolesMap ) ; ServiceBuilder < ? > builder = serviceTarget . addService ( realmServiceName , realmService ) ; builder . addDependency ( REQUIRED , SERVICE_NAME . append ( securityDomain ) , SecurityDomainContext . class , realmService . getSecurityDomainContextInjector ( ) ) . setInitialMode ( ACTIVE ) . install ( ) ; WebDeploymentService webDeploymentService = new WebDeploymentService ( webContext , injectionContainer ) ; if ( moduleDescription != null ) { webDeploymentService . getNamespaceSelector ( ) . setValue ( new org . jboss . msc . value . ImmediateValue < org . jboss . as . naming . context . NamespaceContextSelector > ( moduleDescription . getNamespaceContextSelector ( ) ) ) ; } builder = serviceTarget . addService ( deploymentServiceName , webDeploymentService ) . addDependency ( JBOSS_WEB_HOST . append ( hostName ) , VirtualHost . class , new WebContextInjector ( webContext ) ) . addDependencies ( injectionContainer . getServiceNames ( ) ) . addDependency ( realmServiceName , Realm . class , webDeploymentService . getRealm ( ) ) . addDependencies ( deploymentUnit . getAttachmentList ( WEB_DEPENDENCIES ) ) . addDependency ( JndiNamingDependencyProcessor . serviceName ( deploymentUnit ) ) ; if ( ( metaData . getDistributable ( ) ) != null ) { final DistributedCacheManagerFactory factory = DistributableSessionManager . getDistributedCacheManagerFactory ( ) ; if ( factory != null ) { <START_BUG> builder . addDependencies ( factory . getDependencies ( metaData ) ) ; <END_BUG> } } builder . install ( ) ; } catch ( ServiceRegistryException e ) { throw new DeploymentUnitProcessingException ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>add<seq2seq4repair_space>JBoss<seq2seq4repair_space>web<seq2seq4repair_space>deployment<seq2seq4repair_space>service" , e ) ; } final ModelNode node = deploymentUnit . getDeploymentSubsystemModel ( "web" ) ; node . get ( "context-root" ) . set ( ( "" . equals ( pathName ) ? "//" : pathName ) ) ; node . get ( "virtual-host" ) . set ( hostName ) ; processManagement ( deploymentUnit , metaData ) ; } void processManagement ( final DeploymentUnit unit , JBossWebMetaData metaData ) { } }

Fix:
builder . addDependencies ( OPTIONAL , factory . getDependencies ( metaData ) ) ;