Applies to: JBPM 3.1.2, JBoss 4.0.5-GA
Everything starts with a beautiful concept but has to pass past those nasty errors. The same applies to this JBPM project, everything was nice, I have seen it running and then I was supposed to take the sources, clean, organize and enhance. Everything ok until now. The only problem is that when deploying the JBPM (sar) service there was this error:
16:09:17,402 ERROR [CommandExecutorThread] org.hibernate.HibernateException: Could not instantiate cache implementation
The first idea was to enable DEBUG logging but the result was not much cleared:
org.hibernate.HibernateException: Could not instantiate cache implementation at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:64) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:214) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218) at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:90) at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:74) at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:78) at org.jbpm.persistence.db.DbPersistenceService.getMessagingSession(DbPersistenceService.java:235) at org.jbpm.JbpmContext.getMessagingSession(JbpmContext.java:521) at org.jbpm.msg.db.DbMessageService.<init>(DbMessageService.java:49) at org.jbpm.msg.db.DbMessageServiceFactory.openService(DbMessageServiceFactory.java:32) at org.jbpm.svc.Services.getService(Services.java:136) at org.jbpm.svc.Services.getMessageService(Services.java:172) at org.jbpm.msg.command.CommandExecutorThread.executeCommand(CommandExecutorThread.java:112) at org.jbpm.msg.command.CommandExecutorThread.run(CommandExecutorThread.java:79)Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache] at org.hibernate.cache.NoCacheProvider.buildCache(NoCacheProvider.java:21) at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:61) ... 13 more16:09:17,402 DEBUG [JbpmContext] closing JbpmContext16:09:17,402 DEBUG [Services] closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@71dfd716:09:17,402 ERROR [CommandExecutorThread] org.hibernate.HibernateException: Could not instantiate cache implementation
Apparently the cache implementation could not been found or it was expecting some configuration properties which where not set. I checked in my deploy/lib directory and the ehcache.jar was there. I started to modify the hibernate.hbm.xml which was basically the one from the jbpm examples and which was not working.
First successful try:
<property name="hibernate.cache.use_second_level_cache">false</property><property name="hibernate.cache.use_query_cache">false</property>
This seems to work, however it disables all the cache which is not exactly what I want.
Second successful try:
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property><!-- <property name="hibernate.cache.use_second_level_cache">false</property><property name="hibernate.cache.use_query_cache">false</property> -->
In the mean time I also tried:
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property><!-- <property name="hibernate.cache.use_second_level_cache">false</property><property name="hibernate.cache.use_query_cache">false</property> -->
which also worked.
Apparently all was related to this in hibernate documentation, as it seems EhCache is no longer a default implementation and this was what JPBM was complaing about:
“You have the option to tell Hibernate which caching implementation to use by specifying the name of a class that implements org.hibernate.cache.CacheProvider using the property hibernate.cache.provider_class. … Note that versions prior to 3.2 defaulted to use EhCache as the default cache provider; that is no longer the case as of 3.2.”
Warning: just undeploying/deploying the sar gave me very unreplicable results. The only way I could verify the configuration correctly each way was to restart the container :((
Links with helped me with this:
- http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-cache
- http://jboss.org/index.html?module=bb&op=viewtopic&t=93522&postdays=0&postorder=asc&start=10
Comments:
Mehrad Seyed Sadegh -
You saved me a full day workin hour !
Cheers
Len -
Thank you for the broken link info. Fixed.
Avi Bluestein -
After having given up on finding a resolution in the web - I found this post which saved the day!
I don’t know why, but an exact clone of another system where it works with EhCache, doesn’t work and throws this error!
The HashtableCache works and solves the problem.
WEIRD!!!!
Fernando -
Yeap..thanks a lot ..though my issue was in mixing jbpm with spring…i got the same error too..so now..it works..
BTW link is broken
Shilpa -
Thanks, this helped in resolving the similar problem we are facing
Vortex -
Your entry helped me a lot. Thanks, I had similar problems and it worked just fine. The link you provided to Hibernate documentation is broken, apparently it does not reside there anymore! Anyhow, thanks a lot.
Ro -
Thanks a lot!!
Sodara -
Excellent post, it helped me on this stupid error! I was going to put like you the 2 options with false, but in fact we just have to specify the provider class… What a pity it’s not in the reference doc! Thanks a lot for your post!