Program: 63883
Project: 63883
Buggy source:
public PersistenceContext get(String persistenceUnitName,URI defaultURI,String version,Map<String,Object> initializationProperties){
  PersistenceContext persistenceContext=getDynamicPersistenceContext(persistenceUnitName,version);
  if (persistenceContext == null) {
    try {
      DynamicClassLoader dcl=new DynamicClassLoader(Thread.currentThread().getContextClassLoader());
      Map<String,Object> properties=new HashMap<String,Object>();
      properties.put(PersistenceUnitProperties.CLASSLOADER,dcl);
      if (initializationProperties != null) {
        properties.putAll(initializationProperties);
      }
      EntityManagerFactoryImpl factory=(EntityManagerFactoryImpl)Persistence.createEntityManagerFactory(persistenceUnitName,properties);
      ClassLoader sessionLoader=factory.getServerSession().getLoader();
      if (!DynamicClassLoader.class.isAssignableFrom(sessionLoader.getClass())) {
        properties=new HashMap<String,Object>();
        dcl=new DynamicClassLoader(sessionLoader);
        properties.put(PersistenceUnitProperties.CLASSLOADER,dcl);
        if (initializationProperties != null) {
          properties.putAll(initializationProperties);
        }
        factory.refreshMetadata(properties);
      }
      if (factory != null) {
        persistenceContext=bootstrapPersistenceContext(persistenceUnitName,factory,defaultURI,version,true);
        Set<PersistenceContext> persistenceContextSet=getDynamicPersistenceContextSet(persistenceUnitName);
        if (persistenceContext != null) {
          if (persistenceContextSet == null) {
            persistenceContextSet=new HashSet<PersistenceContext>();
          }
          persistenceContextSet.add(persistenceContext);
synchronized (this) {
            dynamicPersistenceContexts.put(persistenceUnitName,persistenceContextSet);
          }
        }
      }
    }
 catch (    Exception e) {
      JPARSLogger.exception("String_Node_Str",new Object[]{(String)DataStorage.get(DataStorage.REQUEST_UNIQUE_ID),persistenceUnitName,e.toString()},e);
    }
  }
  if ((persistenceContext != null) && (!persistenceContext.isWeavingEnabled())) {
    JPARSLogger.fine("String_Node_Str",new Object[]{(String)DataStorage.get(DataStorage.REQUEST_UNIQUE_ID)});
    throw JPARSException.invalidConfiguration((String)DataStorage.get(DataStorage.REQUEST_UNIQUE_ID),Status.INTERNAL_SERVER_ERROR.getStatusCode());
  }
  return persistenceContext;
}

Fixed version (ground truth):
public PersistenceContext get(String persistenceUnitName,URI defaultURI,String version,Map<String,Object> initializationProperties){
  PersistenceContext persistenceContext=getDynamicPersistenceContext(persistenceUnitName,version);
  if (persistenceContext == null) {
    try {
      DynamicClassLoader dcl=new DynamicClassLoader(Thread.currentThread().getContextClassLoader());
      Map<String,Object> properties=new HashMap<String,Object>();
      properties.put(PersistenceUnitProperties.CLASSLOADER,dcl);
      if (initializationProperties != null) {
        properties.putAll(initializationProperties);
      }
      EntityManagerFactoryImpl factory=(EntityManagerFactoryImpl)Persistence.createEntityManagerFactory(persistenceUnitName,properties);
      ClassLoader sessionLoader=factory.getServerSession().getLoader();
      if (!DynamicClassLoader.class.isAssignableFrom(sessionLoader.getClass())) {
        properties=new HashMap<String,Object>();
        dcl=new DynamicClassLoader(sessionLoader);
        properties.put(PersistenceUnitProperties.CLASSLOADER,dcl);
        if (initializationProperties != null) {
          properties.putAll(initializationProperties);
        }
        factory.refreshMetadata(properties);
      }
      if (factory != null) {
        persistenceContext=bootstrapPersistenceContext(persistenceUnitName,factory,defaultURI,version,true);
        Set<PersistenceContext> persistenceContextSet=getDynamicPersistenceContextSet(persistenceUnitName);
        if (persistenceContext != null) {
          if (persistenceContextSet == null) {
            persistenceContextSet=new HashSet<PersistenceContext>();
          }
          persistenceContextSet.add(persistenceContext);
synchronized (this) {
            dynamicPersistenceContexts.put(persistenceUnitName,persistenceContextSet);
          }
        }
      }
    }
 catch (    Exception e) {
      JPARSLogger.exception("String_Node_Str",new Object[]{DataStorage.get(DataStorage.REQUEST_UNIQUE_ID),persistenceUnitName,e.toString()},e);
    }
  }
  if ((persistenceContext != null) && (!persistenceContext.isWeavingEnabled())) {
    JPARSLogger.fine("String_Node_Str",new Object[]{DataStorage.get(DataStorage.REQUEST_UNIQUE_ID)});
    throw JPARSException.invalidConfiguration(Status.INTERNAL_SERVER_ERROR.getStatusCode());
  }
  return persistenceContext;
}