Возьми этот класс HibernateUtil. Он загружает XML и файлы свойств без стандартного имени. Надеюсь, что это будет полезно.
public class HibernateUtil2 {
private static final SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
URL r1 = HibernateUtil2.class.getResource("/hibernate2.cfg.xml");
Configuration c = new Configuration().configure(r1);
try {
InputStream is = HibernateUtil2.class.getResourceAsStream("/hibernate2.properties");
Properties props = new Properties();
props.load(is);
c.addProperties(props);
} catch (Exception e) {
LOG.error("Error al leer las propiedades", e);
}
return c.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
LOG.error("Error al construir SessionFactory", ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}