14 Replies Latest reply on Jul 19, 2016 9:43 AM by Flemming Harms

    Problem with Wildfly 8.2 and JPA 2.1

    Flemming Harms Novice

      Folks,


      I’m doing a bit of legacy hacking someone would say. The short story is I’m trying to make Wildfly 8.2 work with JPA 2.1 & Hibernate 4.3.11.Final. My initial plan was to use Hibernate 5.2 but didn’t have much luck, so decided to go with a version closer to the one shipped with Wildfly 8 and later with a new version.


      So far I have created a custom Hibernate modules containing the relevant API’s for JPA2.1 and jar files. Created a Arquillian test for testing it work as expected, but get an error when Hibernate is running it’s configuration step.


      Any idea why I get an ClassCastException, classloader issue or is it even possible?


      Thanks!


      18:06:37,870 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 23) HHH000397: Using ASTQueryTranslatorFactory
      18:06:37,871 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 23) MSC000001: Failed to start service jboss.persistenceunit."jpa2wildfly.war#hibernate52Pu": org.jboss.msc.service.StartException in service jboss.persistenceunit."jpa2wildfly.war#hibernate52Pu": org.hibernate.HibernateException: could not instantiate QueryTranslatorFactory: org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
        at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_51]
        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.2.0.Final.jar:8.2.0.Final]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_51]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_51]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]
        at org.jboss.threads.JBossThread.run(JBossThread.java:122)
      Caused by: org.hibernate.HibernateException: could not instantiate QueryTranslatorFactory: org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory
        at org.hibernate.cfg.SettingsFactory.createQueryTranslatorFactory(SettingsFactory.java:508) [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:264) [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
        at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2444) [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2440) [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857) [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845)
        at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844)
        at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
        ... 8 more
      Caused by: java.lang.ClassCastException: org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory cannot be cast to org.hibernate.hql.spi.QueryTranslatorFactory
        at org.hibernate.cfg.SettingsFactory.createQueryTranslatorFactory(SettingsFactory.java:503) [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
        ... 18 more
      


      jboss-deployment-structure.xml


      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
         <deployment>
             <exclusions>
                 <module name="org.hibernate" />
                 <module name="org.hibernate.envers" />
                 <module name="org.hibernate.commons-annotations" />
             </exclusions>
             <dependencies>
                 <module name="javax.api" slot="4.3.11.Final"/>
                 <module name="javax.annotation.api" slot="4.3.11.Final"/>
                 <module name="javax.enterprise.api" slot="4.3.11.Final"/>
                 <module name="javax.persistence.api" slot="4.3.11.Final"/>
                 <module name="javax.transaction.api" slot="4.3.11.Final"/>
                 <module name="javax.validation.api" slot="4.3.11.Final"/>
                 <module name="org.hibernate" slot="4.3"/>
             </dependencies>
         </deployment>
      </jboss-deployment-structure>
      


      The custom module is build on the javax modules from Wildfly 9 and the Hibernate 4.3.11.Final


      .
      |____com
      | |____fasterxml
      | | |____classmate
      | | | |____4.3.11.Final
      | | | | |____classmate-1.1.0.jar
      | | | | |____module.xml
      | | |____jackson
      | | | |____core
      | | | | |____jackson-annotations
      | | | | | |____4.3.11.Final
      | | | | | | |____jackson-annotations-2.5.4.jar
      | | | | | | |____module.xml
      | | | | |____jackson-core
      | | | | | |____4.3.11.Final
      | | | | | | |____jackson-core-2.5.4.jar
      | | | | | | |____module.xml
      | | | | |____jackson-databind
      | | | | | |____4.3.11.Final
      | | | | | | |____jackson-databind-2.5.4.jar
      | | | | | | |____module.xml
      | | | |____jaxrs
      | | | | |____jackson-jaxrs-json-provider
      | | | | | |____4.3.11.Final
      | | | | | | |____jackson-jaxrs-base-2.5.4.jar
      | | | | | | |____jackson-jaxrs-json-provider-2.5.4.jar
      | | | | | | |____jackson-module-jaxb-annotations-2.5.4.jar
      | | | | | | |____module.xml
      |____javax
      | |____annotation
      | | |____api
      | | | |____4.3.11.Final
      | | | | |____jboss-annotations-api_1.2_spec-1.0.0.Final.jar
      | | | | |____module.xml
      | |____api
      | | |____4.3.11.Final
      | | | |____module.xml
      | |____enterprise
      | | |____api
      | | | |____4.3.11.Final
      | | | | |____cdi-api-1.2.jar
      | | | | |____module.xml
      | |____persistence
      | | |____api
      | | | |____4.3.11.Final
      | | | | |____hibernate-jpa-2.1-api-1.0.0.Final.jar
      | | | | |____jbosgi-xservice.properties
      | | | | |____module.xml
      | |____sql
      | | |____api
      | | | |____4.3.11.Final
      | | | | |____jboss-javax-sql-api_7.0_spec-2.0.0.Final.jar
      | | | | |____module.xml
      | |____transaction
      | | |____api
      | | | |____4.3.11.Final
      | | | | |____jboss-transaction-api_1.2_spec-1.0.0.Final.jar
      | | | | |____module.xml
      | |____validation
      | | |____api
      | | | |____4.3.11.Final
      | | | | |____module.xml
      | | | | |____validation-api-1.1.0.Final.jar
      |____modules-tree-dir.txt
      |____org
      | |____hibernate
      | | |____4.3
      | | | |____module.xml
      | | |____4.3.11.Final
      | | | |____hibernate-core-4.3.11.Final.jar
      | | | |____module.xml
      | | |____commons-annotations
      | | | |____4.3.11.Final
      | | | | |____hibernate-commons-annotations-4.0.5.Final.jar
      | | | | |____module.xml
      | | |____entitymanager
      | | | |____4.3.11.Final
      | | | | |____hibernate-entitymanager-4.3.11.Final.jar
      | | | | |____module.xml
      | | |____envers
      | | | |____4.3.11.Final
      | | | | |____hibernate-envers-4.3.11.Final.jar
      | | | | |____module.xml
      | | |____jipijapa-hibernate4_3
      | | | |____4.3
      | | | | |____module.xml
      | | | |____4.3.11.Final
      | | | | |____jipijapa-hibernate4-3-1.0.1.Final.jar
      | | | | |____module.xml
      


      /Flemming.