Program: 28528
Project: 28528
Buggy source:
/** 
 * CreateEMFs and save them in persistence
 * @param context
 */
private void createEMFs(DeploymentContext context){
  Application application=context.getModuleMetaData(Application.class);
  Set<BundleDescriptor> bundles=application.getBundleDescriptors();
  boolean hasScopedResource=false;
  final List<PersistenceUnitDescriptor> referencedPus=new ArrayList<PersistenceUnitDescriptor>();
  for (  BundleDescriptor bundle : bundles) {
    Collection<? extends PersistenceUnitDescriptor> pusReferencedFromBundle=bundle.findReferencedPUs();
    for (    PersistenceUnitDescriptor pud : pusReferencedFromBundle) {
      referencedPus.add(pud);
      if (hasScopedResource(pud)) {
        hasScopedResource=true;
      }
    }
  }
  if (hasScopedResource) {
    connectorRuntime.registerDataSourceDefinitions(application);
  }
  PersistenceUnitDescriptorIterator pudIterator=new PersistenceUnitDescriptorIterator(){
    @Override void visitPUD(    PersistenceUnitDescriptor pud,    DeploymentContext context){
      if (referencedPus.contains(pud)) {
        boolean isDas=isDas();
        boolean weavingEnabled=Boolean.valueOf(sc.getArguments().getProperty("String_Node_Str","String_Node_Str"));
        ProviderContainerContractInfo providerContainerContractInfo=weavingEnabled ? new ServerProviderContainerContractInfo(context,connectorRuntime,isDas) : new EmbeddedProviderContainerContractInfo(context,connectorRuntime,isDas);
        try {
          ((ExtendedDeploymentContext)context).prepareScratchDirs();
        }
 catch (        IOException e) {
          throw new RuntimeException(e);
        }
        PersistenceUnitLoader puLoader=new PersistenceUnitLoader(pud,providerContainerContractInfo);
        context.addTransientAppMetaData(getUniquePuIdentifier(pud),puLoader);
      }
    }
  }
;
  pudIterator.iteratePUDs(context);
}

Fixed version (ground truth):
/** 
 * CreateEMFs and save them in persistence
 * @param context
 */
private void createEMFs(DeploymentContext context){
  Application application=context.getModuleMetaData(Application.class);
  Set<BundleDescriptor> bundles=application.getBundleDescriptors();
  boolean hasScopedResource=false;
  final List<PersistenceUnitDescriptor> referencedPus=new ArrayList<PersistenceUnitDescriptor>();
  for (  BundleDescriptor bundle : bundles) {
    Collection<? extends PersistenceUnitDescriptor> pusReferencedFromBundle=bundle.findReferencedPUs();
    for (    PersistenceUnitDescriptor pud : pusReferencedFromBundle) {
      referencedPus.add(pud);
      if (hasScopedResource(pud)) {
        hasScopedResource=true;
      }
    }
  }
  if (hasScopedResource) {
    connectorRuntime.registerDataSourceDefinitions(application);
  }
  PersistenceUnitDescriptorIterator pudIterator=new PersistenceUnitDescriptorIterator(){
    @Override void visitPUD(    PersistenceUnitDescriptor pud,    DeploymentContext context){
      if (referencedPus.contains(pud)) {
        if (!PersistenceUnitTransactionType.JTA.toString().equals(pud.getTransactionType())) {
          String msg=localStrings.getString("String_Node_Str",new Object[]{pud.getName(),pud.getTransactionType()});
          throw new DeploymentException(msg);
        }
        boolean isDas=isDas();
        boolean weavingEnabled=Boolean.valueOf(sc.getArguments().getProperty("String_Node_Str","String_Node_Str"));
        ProviderContainerContractInfo providerContainerContractInfo=weavingEnabled ? new ServerProviderContainerContractInfo(context,connectorRuntime,isDas) : new EmbeddedProviderContainerContractInfo(context,connectorRuntime,isDas);
        try {
          ((ExtendedDeploymentContext)context).prepareScratchDirs();
        }
 catch (        IOException e) {
          throw new RuntimeException(e);
        }
        PersistenceUnitLoader puLoader=new PersistenceUnitLoader(pud,providerContainerContractInfo);
        context.addTransientAppMetaData(getUniquePuIdentifier(pud),puLoader);
      }
    }
  }
;
  pudIterator.iteratePUDs(context);
}