Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3
Full stack trace of any exception that occurs:
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
Initial SessionFactory creation failed.java.lang.NullPointerException
27/Set/2007 15:18:05 org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
27/Set/2007 15:18:05 org.apache.catalina.core.StandardContext start
SEVERE: Context [/formacao] startup failed due to previous errors
Name and version of the database you are using: MySQL Server 5
Hi
My purpose is to have all the configuration files for my webapp (tomcat 6) in WEB-INF, including hibernate config and mapping files.
My hibernate initialization is made on a HibernateUtil class, that is called on a Servlet Filter.
I had change the code from:
Code:
...
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();
} 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);
}
}
...
To:
Code:
...
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
String path=((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getRealPath("/WEB-INF");
sessionFactory = new Configuration().configure(path + File.separator + "hibernate.cfg.xml").buildSessionFactory();
} 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);
}
}
...
Well since i had this change i can't even load the application, no exception is throw, putting some breakpoints on the above code, does nothing, debug doesn't fire.
When i rollback my changes, the application works... so this is really caused by hibernate.
I'm out of ideas...
Thanks in advance.