How to properly downgrade Hibernate version in Wildfly 8

628 views
Skip to first unread message

Matt Sell

unread,
Apr 28, 2021, 11:28:33 AM4/28/21
to WildFly

I'm trying to port a webapp from JBoss AS7 to Wildfly 8 because we are switching to using Java 8.

The webapp uses JBPM 6.0 which seems to have compatibility issues with the Hibernate version that Wildfly 8 ships with (4.3). I've tried upgrading to a newer jbpm but that caused problems as well.

I'm trying to downgrade to just use the hibernate version that AS7 uses (Hibernate 4.2.0.CR1) because I know that library works.

I've attempted to replace the Hibernate related jars and module.xml from the ones from AS7 in:
wildfly-8.0.0.Final/modules/system/layers/base/org/hibernate/main

hibernate-core-4.2.0.CR1.jar 
hibernate-entitymanager-4.2.0.CR1.jar 
hibernate-infinispan-4.2.0.CR1.jar 
module.xml

and
wildfly-8.0.0.Final/modules/system/layers/base/org/hibernate/envers/main/

hibernate-envers-4.2.0.CR1.jar 
module.xml

but I'm currently getting stack traces when starting up:

2021-04-28 15:18:25,845 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 58) MSC000001: Failed to start service jboss.persistenceunit."peace-web.war#org.jbpm.persistence.jpa": org.jboss.msc.service.StartException in service jboss.persistenceunit."peace-web.war#org.jbpm.persistence.jpa": javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
        at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_272]
        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474)
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_272]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_272]
        at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_272]
        at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) [hibernate-entitymanager-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) [hibernate-entitymanager-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74) [hibernate-entitymanager-4.2.0.CR1.jar:4.2.0.CR1]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167) [wildfly-jpa-8.0.0.Final.jar:8.0.0.Final]
        ... 8 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:186) [hibernate-core-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150) [hibernate-core-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:264) [hibernate-core-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742) [hibernate-core-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94) [hibernate-entitymanager-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) [hibernate-entitymanager-4.2.0.CR1.jar:4.2.0.CR1]
        ... 13 more
Caused by: org.hibernate.cache.CacheException: Unable to start region factory
        at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:323) [hibernate-infinispan-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:70) [hibernate-core-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:40) [hibernate-core-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:35) [hibernate-core-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:91) [hibernate-core-4.2.0.CR1.jar:4.2.0.CR1]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176) [hibernate-core-4.2.0.CR1.jar:4.2.0.CR1]
        ... 19 more
Caused by: java.lang.NoSuchMethodError: org.jboss.as.clustering.msc.ServiceContainerHelper.getCurrentServiceContainer()Lorg/jboss/msc/service/ServiceContainer;
        at org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory.createCacheManager(InfinispanRegionFactory.java:80)
        at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:308) [hibernate-infinispan-4.2.0.CR1.jar:4.2.0.CR1]
        ... 24 more


Am I putting the jars in the wrong directories?
Am I missing some jars?
Do I need to change something in persistence.xml for it to work?

I'm using this provider in persistence.xml
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

Any help would be greatly appreciated!


Paul Ferraro

unread,
Apr 28, 2021, 2:16:38 PM4/28/21
to WildFly
To downgrade Hibernate from 4.3 to 4.2, you will need to recompile WF8 from source, since the org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory (a WF class) extends org.hibernate.cache.infinispan.InfinispanRegionFactory (a hibernate-infinispan class).

Matt Sell

unread,
Apr 28, 2021, 2:24:35 PM4/28/21
to WildFly
I see, thank you, Paul.

What about packaging hibernate 4.2 with my application? that's possible right?

Set the providerModule to "application" in my persistence.xml ? then make some changes to my pom.xml? (not sure which dependencies do I need to include?)
I was reading this document here:

It mentions I may need to include jijijapa jar as well?

Thanks

Paul Ferraro

unread,
Apr 29, 2021, 5:41:47 PM4/29/21
to WildFly
Scott Marlow is going to be your best resource for how best to handle different hibernate versions.
I suggest contacting him within the #wildfly-user stream on wildfly.zulipchat.com.

Scott Marlow

unread,
Apr 29, 2021, 8:21:35 PM4/29/21
to WildFly
You missed switching to use the jipijapa-hibernate4-1-1.0.1.Final.jar which integrates with Hibernate ORM 4.2 (really targeted integration with ORM 4.1 but also worked with 4.2).

I would continue with your attempt to update the hibernate/main folder.  You need to update the module.xml to reference the "jipijapa-hibernate4-1-1.0.1.Final.jar" (you can copy this jar from the wildfly-8.0.0.Final/modules/system/layers/base/org/hibernate/4.1 folder).  I would use the right file names instead of trying to copy over the ORM 4.3 jars, so just update the module.xml (see the various "resource-root" lines in module.xml) to reference the Hibernate 4.2 jar names (you can remove the references to the Hibernate ORM 4.3 jar files). 

Be sure to switch to the hibernate-envers-4.2.0.CR1.jar as well.

Scott

Matt Sell

unread,
Apr 29, 2021, 11:33:19 PM4/29/21
to WildFly
Thank you for the helpful replies.

I think I got it working by packaging Hibernate 4.2 and Jipajapa jar, but hit another issue related to compatibility between jbpm 6.0 and Wildfly 8.

I'm attempting to upgrade the application to jbpm 6.2 which I think should work ok with Hibernate 4.3 and Wildfly 8, I'm hitting some issues but I think they're just related to changes between jbpm 6.0 and 6.2 so I may need to tweak something in my application.

Will follow up on the jbpm forums if I need more help.

Thanks,
Matt
Reply all
Reply to author
Forward
0 new messages