-->
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: could not instantiate CacheProvider: net.sf.ehcache.hibernat
PostPosted: Tue Feb 03, 2004 12:14 pm 
Newbie

Joined: Tue Feb 03, 2004 11:58 am
Posts: 11
Quote:
"could not instantiate CacheProvider: net.sf.ehcache.hibernat" is the message thay I receive when trying to run the following code:

Code:
package com.hibernate.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.List;

import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;

public class HibernateTestMain {

   public static void main(String[] args) {
         
      try {
         HibernateTest ht = new HibernateTest("First Test");

   
      }
      catch(Exception e) {
         System.out.println("[Error]: " + e.getMessage());
      }
   }
}

The HibernateTest class is as follows:
Code:
package com.hibernate.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.List;

import junit.framework.TestCase;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;

public class HibernateTest extends TestCase
{
   private Session session;
   private Department department;
   private Employee manager;
   private static final int employeeId = 512;
   private static final int departmentId = 444;
   private Employee employee;
   private static SessionFactory sessionFactory;
 
   static {
      try
      {
         Configuration cfg = new Configuration();
         cfg.addClass(com.hibernate.test.Employee.class);
         cfg.addClass(com.hibernate.test.Department.class);
         sessionFactory = cfg.buildSessionFactory();
      }
      catch (Exception e)
      {
         //throw new RuntimeException("couldn't get connection");
         System.out.println("[Error]: " + e.getMessage());
      }
   }

   public HibernateTest(String testName)
   {
      super(testName);
   }

   public void setUp() throws Exception
   {
                    ...
   }

   public void testCreateAndReadDepartment() throws Exception
   {
                    ...
   }

   public void testCreateAndReadEmployee() throws Exception
   {
                    ...
   }

   public void testUpdateEmployeeSameSession() throws Exception
   {
                    ...
   }

   public void testUpdateEmployeeNewSession() throws Exception
   {
                    ...
   }

   public void testQuery() throws Exception
   {
                    ...
   }

   private static void wipeDatabase() throws Exception
   {
                    ...
   }
}

The hibernate.properties file is as follows: (IBM DB2 8.1)

hibernate.connection.driver_class = COM.ibm.db2.jdbc.app.DB2Driver
hibernate.connection.url = jdbc:db2:BANKDATA
hibernate.connection.username = prnicn
hibernate.connection.password = pentagon
hibernate.dialect = net.sf.hibernate.dialect.DB2Dialect

The stack trace is as follows:

Code:
[INFO] Environment - -Hibernate 2.1.1
[INFO] Environment - -loaded properties from resource hibernate.properties: {hibernate.connection.username=prnicn, hibernate.connection.password=pentagon, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.DB2Dialect, hibernate.connection.url=jdbc:db2:BANKDATA, hibernate.connection.driver_class=COM.ibm.db2.jdbc.app.DB2Driver}
[INFO] Environment - -using CGLIB reflection optimizer
[INFO] Environment - -JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled
[INFO] Environment - -using workaround for JVM bug in java.sql.Timestamp
[INFO] Configuration - -Mapping resource: com/hibernate/test/Employee.hbm.xml
[INFO] Binder - -Mapping class: com.hibernate.test.Employee -> employee
[INFO] Configuration - -Mapping resource: com/hibernate/test/Department.hbm.xml
[INFO] Binder - -Mapping class: com.hibernate.test.Department -> department
[INFO] Configuration - -processing one-to-many association mappings
[INFO] Configuration - -processing one-to-one association property references
[INFO] Configuration - -processing foreign key constraints
[INFO] Dialect - -Using dialect: net.sf.hibernate.dialect.DB2Dialect
[INFO] SettingsFactory - -Use outer join fetching: true
[INFO] DriverManagerConnectionProvider - -Using Hibernate built-in connection pool (not for production use!)
[INFO] DriverManagerConnectionProvider - -Hibernate connection pool size: 20
[INFO] DriverManagerConnectionProvider - -using driver: COM.ibm.db2.jdbc.app.DB2Driver at URL: jdbc:db2:BANKDATA
[INFO] DriverManagerConnectionProvider - -connection properties: {user=prnicn, password=pentagon}
[INFO] TransactionManagerLookupFactory - -No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
[INFO] SettingsFactory - -Use scrollable result sets: true
[INFO] SettingsFactory - -Query language substitutions: {}
[INFO] SettingsFactory - -cache provider: net.sf.ehcache.hibernate.Provider
[Error]: could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider






Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 12:20 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Copy ehcache.jar to your classpath and read lib/README.txt.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 1:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
FAQ: http://www.hibernate.org/74.html#A25


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.