Instance instance = null;
try {
// Create new instance
try {
final InstanceContext context = beanContext.newInstance();
// Wrap-up everthing into a object
instance = new Instance(beanContext, primaryKey, context.getBean(), context.getCreationalContext(), context.getInterceptors(), entityManagers);
} catch (Throwable throwable) {
ThreadContext callContext = ThreadContext.getThreadContext();
handleSystemException(callContext.getTransactionPolicy(), throwable, callContext);
throw new IllegalStateException(throwable); // should never be reached