hibernateconfigurationinfinispanwildfly-11

How to reactivate infinispan on Wildfly 11, when using hibernate-orm-modules to use a more current Hibernate?


I followed this jboss guide to parallel-install a newer hibernate version into WF11. Given the last sentences:

When using these modules you’re going to give up on some of the integration which the application server normally automates.

For example enabling an Infinispan 2nd level cache is straight forward when using the default Hibernate ORM module, as WildFly will automatically setup the dependency to the Infinispan and clustering components. When using these custom modules such integration will no longer work automatically: you can still enable all normally available features but these will require explicit configuration, as if you were running Hibernate in a different container, or in no container.

I adjusted the jboss-deployment-structure to explicitely require infinispan as

<jboss-deployment-structure>
    <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
        <!-- This corresponds to the top level deployment. For a war this is the war's module, for an ear -->
        <!-- This is the top level ear module, which contains all the classes in the EAR's lib folder     -->
        <deployment>
            <dependencies>
                <module name="org.hibernate.infinispan" services="import" slot="${version.org.hibernate}"/>
            </dependencies>
        </deployment>
        <sub-deployment name="some-report-service-${project.version}.war">
            <exclusions>
                <module name="org.jboss.resteasy.resteasy-jackson2-provider"/>
                <module name="org.jboss.resteasy.resteasy-jettison-provider"/>
            </exclusions>
            <dependencies>
                <module name="org.jboss.resteasy.resteasy-jackson-provider" services="import"/>
                <module name="org.hibernate.infinispan" services="import" slot="${version.org.hibernate}"/>
            </dependencies>
        </sub-deployment>
[...]

Unfortunately, I still can't deploy the EAR file to my Wildfly with this Stacktrace

 Unable to build Hibernate SessionFactory
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:195)
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:125)
        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:640)
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:209)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: DM_DERIVATEV] Unable to build Hibernate SessionFactory
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:970)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:895)
        at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167)
        ... 7 more
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:271)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
        at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.getService(SessionFactoryServiceRegistryImpl.java:80)
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:243)
        at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:892)
        ... 9 more
Caused by: org.hibernate.cache.CacheException: HHH025011: Infinispan custom cache command factory not installed (possibly because the classloader where Infinispan lives couldn't find the Hibernate Infinispan cache provider)
        at org.hibernate.cache.infinispan.InfinispanRegionFactory.getCacheCommandFactory(InfinispanRegionFactory.java:743)
        at org.hibernate.cache.infinispan.InfinispanRegionFactory.startRegion(InfinispanRegionFactory.java:600)
        at org.hibernate.cache.infinispan.InfinispanRegionFactory.buildTimestampsRegion(InfinispanRegionFactory.java:390)
        at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:78)
        at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:28)
        at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:20)
        at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:59)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259)
        ... 15 more

What a I missing? Hope you can help me out and best regards,

Marius


Solution

  • Okay, I found the missing link. One has to also adjust the standalone/configuration/standalone.xml file.

    Search: <cache-container name="hibernate" module="org.hibernate.infinispan:4"> Replace: <cache-container name="hibernate" module="org.hibernate.infinispan:5.2">

    5.2 is of course the version you're referring to, adjust it to your needs.

    More detailed on:

    Best regards,

    Marius