-->
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.  [ 5 posts ] 
Author Message
 Post subject: net.sf.hibernate.HibernateException: could not instantiate C
PostPosted: Mon Mar 14, 2005 9:20 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 9:07 am
Posts: 27
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 content

Code:
<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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 12:44 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 9:07 am
Posts: 27
When I debugged I found that error was at lines

Configuration cfg = new Configuration ( ).addClass ( com.CD.class );
SessionFactory sessionFactory = cfg.buildSessionFactory ( );


I tried with-

Configuration cfg = new Configuration ( ).addClass ( com.CD.class );

and

Configuration cfg = new Configuration ( ).addClass ( CD.hbm.xml );

but of no use.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 3:05 am 
Regular
Regular

Joined: Mon Feb 23, 2004 10:42 pm
Posts: 102
Location: Washington DC
Make sure the ehcache jar is in your classpath!

Hence the message
Caused by: java.lang.ClassNotFoundException: net.sf.ehcache.hibernate.Provider

_________________
Matt Veitas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 3:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
So are you using Hibernate2, or Hibernate3. Your post says Hibernate2, yet this is a Hibernate3 forum. So which is it


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 5:18 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 9:07 am
Posts: 27
Yes I am using Hibernate 2 (not Hibernate 3). But I couldn't find where to go for Hibernate2 problems. I tried afew links on your site but could find the Hibernate 2 forum. If you could just tell me the link.......


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.