-->
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: Problem with HIBERNATE and Servlet
PostPosted: Fri Nov 20, 2009 5:44 am 
Newbie

Joined: Wed Nov 18, 2009 11:21 am
Posts: 4
Hi,
i am novice in Hibernate and I would like to realize an application j2ee by using this framework, I followed the example in the documentation of Hibernate (http: // docs.jboss.org / hibernate / stab webapp-servlet) stage by stage but without using maven.
it works very well when I use a simple class Java but when I deploy the application on tomcat by using a servlet nothing works more

the error results from this line of code

Code:
HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();


and this is the list of error

Code:
org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: "Servlet.service()" pour la servlet EventManagerServlet a g�n�r� une exception
java.lang.NoClassDefFoundError
   at org.hibernate.tutorial.web.EventManagerServlet.doGet(EventManagerServlet.java:24)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Unknown Source)



help me Please.


Last edited by mano on Fri Nov 20, 2009 6:27 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Pblem with HIBERNATE and Servlet
PostPosted: Fri Nov 20, 2009 6:14 am 
Newbie

Joined: Fri Nov 20, 2009 6:08 am
Posts: 1
CREATE VIEW `view_rating` AS select `rating`.`id` AS `id`,`rating`.`last_update` AS `last_update`,`casinos`.`name` AS `casino`,`parameters`.`name` AS `parameter`,`rating`.`value` AS `value`,`parameters`.`percent` AS `percent`,((`rating`.`value` / 100) * `parameters`.`percent`) AS `rating_value` from ((`casinos` join `parameters`) join `rating`) where ((`rating`.`casino_id` = `casinos`.`id`) and (`rating`.`parameter_id` = `parameters`.`id`));

Class Transactions:
import org.hibernate.Query;
import org.hibernate.Session;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class Transactions {
public static String QUERY_ALL_CASINOS="from view_rating ";
...
Session session;
private static SessionFactory ourSessionFactory;
static {
try {
ourSessionFactory = new AnnotationConfiguration().
configure("hibernate.cfg.xml").
buildSessionFactory();
}
catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession() throws HibernateException {
return ourSessionFactory.openSession();
}
public List executeHQLQuery(String hql) {
session = getSession();
List resultList=null;
try {
session.beginTransaction();
Query q = session.createQuery(hql);
resultList = q.list();
session.getTransaction().commit();
} catch (HibernateException he) {
he.printStackTrace();
}
return resultList;
}
}
JSP Page:
...
<%
Transactions tr = new Transactions();
List resultList = tr.executeHQLQuery(tr.QUERY_ALL_CASINOS);
for(Object o : resultList) {
out.print("<tr>");
ViewRating casino = (ViewRating)o;
out.print("<td>"+casino.getValue()+"</td>");
out.print("</tr>");
}
http://www.discountsvu.com


Top
 Profile  
 
 Post subject: Re: Pblem with HIBERNATE and Servlet
PostPosted: Fri Nov 20, 2009 6:26 am 
Newbie

Joined: Wed Nov 18, 2009 11:21 am
Posts: 4
what is this code???


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.