Program: 64248
Project: 64248
Buggy source:
public PersistenceContext get(String persistenceUnit,URI defaultURI,Map<String,Object> initializationProperties){
  PersistenceContext app=getDynamicPersistenceContext(persistenceUnit);
  if (app == 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(persistenceUnit,properties);
      ClassLoader sessionLoader=factory.getServerSession().getLoader();
      if (!sessionLoader.getClass().isAssignableFrom(DynamicClassLoader.class)) {
        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) {
        app=bootstrapPersistenceContext(persistenceUnit,factory,defaultURI,true);
      }
    }
 catch (    Exception e) {
      JPARSLogger.exception("String_Node_Str",new Object[]{persistenceUnit,e.toString()},e);
    }
  }
  if (!app.isWeavingEnabled()) {
    throw new JPARSConfigurationException(LoggingLocalization.buildMessage("String_Node_Str",new Object[]{persistenceUnit}));
  }
  return app;
}

Fixed version (ground truth):
public PersistenceContext get(String persistenceUnit,URI defaultURI,Map<String,Object> initializationProperties){
  PersistenceContext app=getDynamicPersistenceContext(persistenceUnit);
  if (app == 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(persistenceUnit,properties);
      ClassLoader sessionLoader=factory.getServerSession().getLoader();
      if (!sessionLoader.getClass().isAssignableFrom(DynamicClassLoader.class)) {
        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) {
        app=bootstrapPersistenceContext(persistenceUnit,factory,defaultURI,true);
      }
    }
 catch (    Exception e) {
      JPARSLogger.exception("String_Node_Str",new Object[]{persistenceUnit,e.toString()},e);
    }
  }
  if ((app != null) && (!app.isWeavingEnabled())) {
    throw new JPARSConfigurationException(LoggingLocalization.buildMessage("String_Node_Str",new Object[]{persistenceUnit}));
  }
  return app;
}