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 instantiatecacheimplementation
The first idea was to enable DEBUG logging but the result was not much cleared:
org.hibernate.HibernateException: Could not instantiatecacheimplementation
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 more
16:09:17,402 DEBUG [JbpmContext] closing JbpmContext
16:09:17,402 DEBUG [Services] closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@71dfd7
16:09:17,402 ERROR [CommandExecutorThread] org.hibernate.HibernateException: Could not instantiatecacheimplementation
Apparently the cacheimplementationcould 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: