It's not a secret anymore!
The moose likes Object Relational Mapping and the fly likes Getting Exception Could not instantiate CacheProvider Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Getting Exception Could not instantiate CacheProvider" Watch "Getting Exception Could not instantiate CacheProvider" New topic

Getting Exception Could not instantiate CacheProvider

Vikram Takkar

Joined: Oct 27, 2005
Posts: 12
while compiling my code i am getting this error

"could not instantiate CacheProvider: org.hibernate.cache.EHCacheProvider"

what is the reason.....? suggest me
[ June 27, 2007: Message edited by: Mark Spritzler ]

Vikram Takkar<br />Programmer
Peter Laurinec
Ranch Hand

Joined: Sep 13, 2004
Posts: 52
In case of such as error you should post whole error message otherwise it is hard to suggest.
I think this might be that you dont have the Hibernate3 classes in classpath.

SCJP 1.5 (done, at last)<br /> <br />"If everything seems to be going well you have obviously overlooked something."
Vikram Takkar

Joined: Oct 27, 2005
Posts: 12
This is my compilation message :

check last few lines of it :-------

0 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.1 rc1
71 [main] INFO org.hibernate.cfg.Environment - not found
101 [main] INFO org.hibernate.cfg.Environment - using CGLIB reflection optimizer
131 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
601 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
611 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
2184 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource: contact.hbm.xml
2804 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: package1.Contact -> CONTACT
3005 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
3035 [main] INFO org.hibernate.cfg.Configuration - processing extends queue
3035 [main] INFO org.hibernate.cfg.Configuration - processing collection mappings
3035 [main] INFO org.hibernate.cfg.Configuration - processing association property references
3035 [main] INFO org.hibernate.cfg.Configuration - processing foreign key constraints
3445 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
3455 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
3455 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
3536 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.sybase.jdbc2.jdbc.SybDriver at URL: jdbc:sybase:Tds:"?JCONNECT_VERSION=5
3566 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=DBA, password=****}
6580 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: Adaptive Server Anywhere, version:
6580 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: jConnect (TM) for JDBC (TM), version: jConnect (TM) for JDBC(TM)/5.5(Build 25137)/P/EBF10000/JDK12/Sun Jan 6 21:57:04 2002
6700 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.SybaseAnywhereDialect
6740 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
6750 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
6750 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
6750 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
6750 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
6760 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
6760 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: null
6760 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
6760 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
6760 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
6770 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
6810 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
6810 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
6810 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
6810 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
6810 [main] INFO org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.EHCacheProvider
could not instantiate CacheProvider: org.hibernate.cache.EHCacheProvider

Exception in thread "main" java.lang.NullPointerException
at package1.SecondExample.main(

what i think is that it is not able to find "ehcache.xml" ... thats why gving this error.. please suggest me
Peter Laurinec
Ranch Hand

Joined: Sep 13, 2004
Posts: 52
Yes sure.
When you want to use a second-level cache (in your case EHCache), there need to be additional configuration file present according to concrete cache implementation.
In this case you should place ehcache.xml to the same location as your hibernate.cfg.xml.
After this everything should be working. If you have more difficulties on using second-level cache with hibernate try to read this article.

Vikram Takkar

Joined: Oct 27, 2005
Posts: 12
Yes i have already made "ehcache.xml" and placed it in the same directory as the "hibernate.cfg.xml"... but i am getting the same error... even i have placed my ehcache.xml file in ecache.jar file.. but the error persists... is there any way that we can insert our ehcache.xml programatically ...please help me...
Vikram Takkar

Joined: Oct 27, 2005
Posts: 12
i am not able to solve the Above problem.... please Help me... how do i remove above Error ... i am stuck at this point .... any help wll be welcomed...
Paul Clapham

Joined: Oct 14, 2005
Posts: 19741

Exception in thread "main" java.lang.NullPointerException
at package1.SecondExample.main(
If this is your problem then I think your diagnosis of the problem is wrong. You're dereferencing a null reference at line 47 of your SecondExample class, in the main() method. Look there.
Vikram Takkar

Joined: Oct 27, 2005
Posts: 12
Yes you are right but what i think is that it is not able to find "EHCACHE.XML" file this is why it is giving this error (Null Pointer Exception).. as i change the name of "EHCACHE.XML" to anyname still ,giving the same error so it is not able to find this file .... moreover when i run my program without caching it runs without any error... so i think problem is just of EHCACHE.XML ... if u have any solution i shall b very thankful
[ November 24, 2005: Message edited by: Vikram Takkar ]
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Weird, we are using ehcache, but we don't have a ehcache.xml file.

Where is your ehcache.jar file. Is it in the same location as the Hibernate jar files?


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
William Pennell

Joined: Jul 26, 2006
Posts: 1
Try org.hibernate.cache.EhCacheProvider instead of org.hibernate.cache.EHCacheProvider.
Ken Ganong

Joined: Jul 19, 2006
Posts: 1
Thanks alot.
I ran into this same problem and stared at it for an hour without noticing the EH capitalization.
I agree. Here's the link:
subject: Getting Exception Could not instantiate CacheProvider
jQuery in Action, 3rd edition