try
{
field.set(instance, factory);
}
catch (IllegalAccessException e)
{
throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
}
catch (IllegalArgumentException e)
{
throw new RuntimeException("Failed in setting EntityManager on setter field: " + field.toString());
}