-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problems to convert from Java Application to Servlet
PostPosted: Wed Sep 20, 2006 10:26 am 
Beginner
Beginner

Joined: Tue Sep 19, 2006 1:48 pm
Posts: 20
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?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 4:32 pm 
Beginner
Beginner

Joined: Tue Sep 19, 2006 1:48 pm
Posts: 20
To answer my question, I had to put all the Hibernate necessary Jars in my JRE directory (C:\Program Files\Java\jre1.5.0_07\lib\ext).

How can I link the Jars of my project (in my web application directory) to Tomcat, where should I put them?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 11:19 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why don't you look at the source code that is bundled with the tutorial and ready to run?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.