I am doing the Hibernate Tutorial and am having troubles with the servlet section. The thing is that if I use the EventManagerServlet.java as a Java Application with a main :
Code:
public static void main(String[] args)
{ HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
...
}
It works properly!
But then if I change it to a servlet with :
Code:
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
try {
HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
...
} catch (Exception ex) {
HibernateUtil.getSessionFactory()
.getCurrentSession().getTransaction().rollback();
throw new ServletException(ex);
}
}
And run it in my browser with the correct URL mapping, I then get this error :
Code:
java.lang.ExceptionInInitializerError
util.HibernateUtil.<clinit>(HibernateUtil.java:16)
events.EventManagerServlet.doGet(EventManagerServlet.java:22)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
and then if I refresh my browser, I get :
Code:
java.lang.NoClassDefFoundError
events.EventManagerServlet.doGet(EventManagerServlet.java:22)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Hibernate version: 3.1.3
Is there anything I am forgetting to transform my program to a Servlet?