Object factory = null;
try
{
factory = PersistenceUnitHandler.getFactory(injectionType, unitName, container);
}
catch (NameNotFoundException e)
{
throw new RuntimeException(e);
}
if (factory == null)
{
throw new RuntimeException("Failed to locate " + error + " of unit name: " + unitName + " for " + container.getIdentifier());
}
try
{
Util.rebind(container.getEnc(), encName, factory);
}
catch (Exception e)
{
throw new RuntimeException("Failed to bind " + error + " of unit name: " + unitName + " ref-name" + encName + " for container " + container.getIdentifier(), e);
}