// build the serviceregistry
final BootstrapServiceRegistryBuilder bootstrapbuilder = new BootstrapServiceRegistryBuilder();
builder = new ServiceRegistryBuilder(bootstrapbuilder.build()).applySettings(properties);
serviceRegistry = builder.buildServiceRegistry();
// Create the SessionFactory from Configuration
sessionFactory = configuration.configure("hibernate.cfg.xml").buildSessionFactory(serviceRegistry);
// Session session = sessionFactory.openSession();
} catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);