Search code examples
springhibernatehazelcastsecond-level-cache

HazelCast Hibernate52 - Throws Unable to resolve name com.hazelcast.hibernate.HazelcastCacheRegionFactory


I'm trying to create a second level cache using hazelcast-hibernate52 (which supports hibernate 5.2.12.Final, I guess) when I run it throws the following exception

Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [com.hazelcast.hibernate.HazelcastCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:126)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:194)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:161)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:67)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:28)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259)
... 47 more

Below are my Spring hazel configurations

 <hz:hazelcast id="instance">
    <hz:config>
    <hz:instance-name>hazelcast</hz:instance-name>
   <!--  <hz:spring-aware /> -->
        <hz:group name="dev" password="dev-password"/>
        <hz:management-center enabled="true" url="http://localhost:9008/hazelcast-mancenter"/> 
        <hz:properties>
            <hz:property name="hazelcast.merge.first.run.delay.seconds">5</hz:property>
            <hz:property name="hazelcast.merge.next.run.delay.seconds">5</hz:property>
        </hz:properties>
        <hz:network port="5701" port-auto-increment="false" port-count="1">
            <hz:join>
            <!-- Enable for auto detection --> 
                <hz:multicast enabled="true" />
                <hz:tcp-ip enabled="false">
                 <hz:members>120.0.0.1</hz:members>
                </hz:tcp-ip>
            </hz:join>
            <hz:interfaces>
            <hz:interface>120.0.0.*</hz:interface>
            </hz:interfaces>
        </hz:network>

These are my spring hibernate configurations

<bean id="tpSessionFactory"
    class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    <property name="dataSource" ref="tpDataSource"></property>
    <property name="hibernateProperties">
        <props>
            <!-- <prop key="hibernate.dialect">${db.dialect}</prop> -->
            <prop key="hibernate.show_sql">${db.show_sql}</prop>
            <prop key="hibernate.hbm2ddl.auto">${db.hbm2ddl.auto}</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">com.hazelcast.hibernate.HazelcastCacheRegionFactory</prop>
<prop key="hibernate.cache.hazelcast.instance_name">hazelcast</prop>
        </props>

and the dependencies which are used are:

<dependency>
        <groupId>com.hazelcast</groupId>
        <artifactId>hazelcast-all</artifactId>
        <version>3.10.4</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.hazelcast</groupId>
        <artifactId>hazelcast-spring</artifactId>
        <version>3.10.4</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.hazelcast</groupId>
        <artifactId>hazelcast-hibernate52</artifactId>
        <version>1.2</version>
    </dependency>

Is there anything which i'm missing in here?


Solution

  • Problem with hazelcast-hibernate52 dependency.

    Looks like the dependency isn't updating or could be some other reasons.

    what I did is, look the git code from here, built a jar out of it and included that into my classpath. Voila! everything seems to work well and good.