Ehcache Second Level Cache working on JBoss Fuse
Issue
- We ave hit an issue with some second level caches that we had set up with Hibernate and Ehcache.
- On JBoss Fuse, we have installed,
spring-jdbc, spring-orm, camel-jpa, jpa-hibernate
features. - When we deploy our application with the following set up in a bundle context as below,
<bean id="rdisAnnotationsSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="hibernateProperties">
<util:properties>
<prop key="hibernate.connection.pool_size">1</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.connection.autocommit">true</prop>
<!-- entity and query caching -->
<prop key="hibernate.cache.use_structured_entries">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.generate_statistic">true</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
</util:properties>
</property>
<property name="namingStrategy" ref="namingStrategy" ></property>
<property name="dataSource" ref="someDataSource" ></property>
</bean>
we get the following below exceptions,
11:12:41,777 | ERROR | ExtenderThread-2 | ContextLoaderListener | 145 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=exampleBundle, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#4': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MyTransactionManager' defined in URL [bundle://<host>/META-INF/spring/bundle-context.xml]: Cannot resolve reference to bean 'XXXAnnotationsSessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rdisAnnotationsSessionFactory' defined in URL [bundle://<host>/META-INF/spring/bundle-context.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]
.............................................
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]
at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:544)[272:org.hibernate.core:4.2.9.Final]
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:292)[272:org.hibernate.core:4.2.9.Final]
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2363)[272:org.hibernate.core:4.2.9.Final]
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2359)[272:org.hibernate.core:4.2.9.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1795)[272:org.hibernate.core:4.2.9.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1868)[272:org.hibernate.core:4.2.9.Final]
........................................................................................
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.cache.ehcache.EhCacheRegionFactory]
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:151)[272:org.hibernate.core:4.2.9.Final]
at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:527)[272:org.hibernate.core:4.2.9.Final]
... 43 more
Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.cache.ehcache.EhCacheRegionFactory
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:318)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)[:1.6.0_45]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_45]
at java.lang.Class.forName0(Native Method)[:1.6.0_45]
at java.lang.Class.forName(Class.java:249)[:1.6.0_45]
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:148)[272:org.hibernate.core:4.2.
Environment
- Red Hat JBoss Fuse
- 6.x
- Hibernate/JPA
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.