Hibernate version:2.1
Mapping documents:<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd"> <hibernate-configuration>
<session-factory name="java:hibernate/HibernateFactory">
<property name="connection.datasource">java:comp/env/oozlooz/hibernate</property> <property name="show_sql">true</property>
<!-- Settings for a remote MySQL database. --> <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">mysql://localhost/oozlooz</property> <property name="connection.username">oozlooz</property> <property name="connection.password">Jerich0</property> <!-- Use the C3P0 connection pool. --> <property name="c3p0.min_size">3</property> <property name="c3p0.max_size">5</property> <property name="c3p0.timeout">1800</property> <!-- Use EHCache but not the query cache. --> <property name="cache.provider_class">net.sf.ehcache.hibernate.Provider</property> <property name="cache.use_query_cache">false</property> <property name="cache.use_minimal_puts">false</property>
<mapping resource="oozlooz/hbm/user.hbm.xml"/> </session-factory> </hibernate-configuration>
Code between sessionFactory.openSession() and session.close():Session sess=HibernateUtil.currentSession(); tx=sess.beginTransaction(); //Get the user class object referring to the table "user" user uObj = new user(); //Create the query Query query=sess.createQuery("SELECT count(userid) FROM user where username= :username"); query.setString("username",username); //Iterate thorugh the result of this query. //If it contains > 0 records, there is already a user registered int userCount=0; for( Iterator it=query.iterate() ; it.hasNext(); ){ userCount++; } if(userCount > 0) //User already Exists. { errors.add("user.exists", new ActionError("joinus.user.exists", username)); } }catch(Exception e){ try{ e.printStackTrace(); if(tx!=null){ tx.rollback(); } }catch(HibernateException he ){ he.printStackTrace(); } }finally{ try{ HibernateUtil.closeSession(); }catch(HibernateException he ){ he.printStackTrace(); }
Full stack trace of any exception that occurs:2004-09-04 15:45:53 StandardWrapperValve[action]: Servlet.service() for servlet action threw exception java.lang.NoClassDefFoundError at oozlooz.forms.JoinForm.validate(JoinForm.java:71) at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:942) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644) at java.lang.Thread.run(Thread.java:536)
Name and version of the database you are using:mysql-4
Debug level Hibernate log excerpt:-
--This is a very basic implementation of Hibernate that I am trying to do. I hve initialized context in Tomcat 5 server.xml and web.xml and copied the HibernateUtil.java code from example. I cant understand what is wrong with this.
Please show me the way !
|