Hi there,
I am about to set up a simple JavaServer Faces Web Application and integrated hibernate quite successfully so far. My problem now is that (after doing some tests without web context) I need to run hibernate in the web application.
I am using the HibernateUtil class as it is explained in the tutorial. I know that this might not be perfect, but I would like to get it running and then think about even better solutions.
My current error when I try to access a simple Servlet that should print out the number of "Images" in my images table: browser output:
java.lang.ExceptionInInitializerError
de.flavor.suevia.web.util.HibernateUtil.<clinit>(Unknown Source)
de.flavor.suevia.web.HibernateTestServlet.doGet(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Before this error I had problems with the connection to my mysql database, I think this was because the hibernate.properties was in the classpath of the web appliation. After I deleted this properties file from the classpath, I now got this error.
The hibernate.cfg.xml is in my web classpath, so this should work.
Do you have any ideas?
Thank you!
Below is the simple servlet code that I am trying to run.
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
Criteria criteria = session.createCriteria(Image.class);
List images = criteria.list();
log.debug("Amount of images found: " + images.size());
response.getOutputStream().println("I've found " + images.size() + " images. It works!");
tx.commit();
HibernateUtil.closeSession();
|