Hi friends ,
I need some urgent help. I am trying out this example and getting an error that says
net.sf.hibernate.HibernateException: could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider
Hibernate version:2
Mapping documents:
------------------------------------------------------------
Code:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.CD"
table="cd">
<id name="Id"
type="int"
unsaved-value="0">
<column name="ID"
sql-type="int"
not-null="true"/>
<generator class="hilo"/>
</id>
<property name="title"/>
<property name="artist"/>
<property name="purchasedate" type="date"/>
<property name="cost" type="double"/>
</class>
</hibernate-mapping>
------------------------------------------------------------
Code between sessionFactory.openSession() and session.close():------------------------------------------------------------
Code:
<%@ page import="net.sf.hibernate.*, net.sf.hibernate.cfg.*, java.util.*, com.*" %>
<%
try {
SessionFactory sessionFactory = new Configuration().buildSessionFactory();
Session ses1 = sessionFactory.openSession();
String action = request.getParameter("submit");
if (action.equals("Pull All CDs")) {
try {
out.println("<html>");
out.println("<table border='1'>");
out.println("<tr><td>Title</td><td>Artist</td><td>cost</td></tr>");
List cds = ses1.find("from CD");
Iterator iter = cds.iterator();
while (iter.hasNext()) {
CD cd = (CD)iter.next();
out.println("<tr><td>");
out.println(cd.getTitle());
out.println("</td><td>");
out.println(cd.getArtist());
out.println("</td><td>");
out.println(cd.getCost());
out.println("</td></tr>");
}
} catch(Exception e) {}
out.println("</table>");
out.println("</html>");
} else {
out.println("Bad Input");
}
ses1.flush();
ses1.close();
} catch (Exception e) {
e.printStackTrace();
}
%>
------------------------------------------------------------
Full stack trace of any exception that occurs:------------------------------------------------------------
Code:
net.sf.hibernate.HibernateException: could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:133)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1132)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:766)
at org.apache.jsp.viewer_jsp._jspService(viewer_jsp.java:50)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
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:595)
Caused by: java.lang.ClassNotFoundException: net.sf.ehcache.hibernate.Provider
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:130)
... 33 more
------------------------------------------------------------
Name and version of the database you are using:-----------------------------------------------------------------
I am using Oracle 9i and below is my hibernate.cfg.xml file contentCode:
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">oracle.jdbc.driver.OracleDriver</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<property name="connection.url">jdbc:oracle:thin:@172.16.4.78:1521:prod</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.username">xxxxxxxxxx</property>
<property name="connection.password">xxxxxxxxxxxx</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
<!-- Mapping files -->
<mapping resource="CD.hbm.xml"/>
</session-factory>
</hibernate-configuration>
-----------------------------------------------------------------
The generated SQL (show_sql=true):
-----------------------------------------------------------------
no sql has been generated so far.
-----------------------------------------------------------------
Debug level Hibernate log excerpt:
I would really appreciate if any one of you could help me out.
Thanks ,
Ashish Abrol