1 Reply Latest reply on Jan 13, 2014 12:48 AM by Shailendra kumar

    Deploy Hibernate 4.3.x on JBoss EAP 6.1 (7.2.0.Final)

    Felix Feisst Newbie

      Hello,

       

      I'm trying to deploy my application ear on JBoss EAP 6.1 with a custom version of Hibernate (version 4.3.x).

      I have created a jboss-deployment-structure.xml that looks like this:

       

      <?xml version='1.0' encoding='UTF-8'?>
      <jboss-deployment-structure>
        <deployment>
          <dependencies>
            <module name="org.slf4j" />
            <module name="org.hibernate.validator" />
            <module name="org.infinispan" />
          </dependencies>
          <exclusions>
            <module name="org.hibernate" />
          </exclusions>
        </deployment>
      </jboss-deployment-structure>
      

       

      However, when I try to deploy the EAR file to the AS I receive the following exception on deployment:

      Unable to instantiate Scanner class: class org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner
         at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
         at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]
         at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.0.Final-redhat-1.jar:2.1.0.Final-redhat-1]
      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: xxx] Unable to instantiate Scanner class: class org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner
         at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1225)
         at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.locateOrBuildScanner(EntityManagerFactoryBuilderImpl.java:767)
         at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.scan(EntityManagerFactoryBuilderImpl.java:720)
         at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:219)
         at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:186)
         at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:45)
         at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:57)
         at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:150)
         at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
         at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
         at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
         ... 4 more
      Caused by: java.lang.ClassCastException: org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner cannot be cast to org.hibernate.jpa.boot.scan.spi.Scanner
         at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.locateOrBuildScanner(EntityManagerFactoryBuilderImpl.java:764)
         ... 14 more
      

       

      In the persistence.xml of the application i have configured:

      <property name="jboss.as.jpa.adapterModule" value="org.jboss.as.jpa.hibernate:4" />
      

       

      which seems not to be compatible with Hibernate 4.3.x

       

      However, I do not know where I can obtain a compatible version of org.jboss.as.jpa.hibernate4.

       

      Any ideas on this?

       

      Thanks,

        Felix

        • 1. Re: Deploy Hibernate 4.3.x on JBoss EAP 6.1 (7.2.0.Final)
          Shailendra kumar Newbie

          The issue seems to be the fact that the EAP 6.1 is JPA 2.0 compliant whereas the Hibernate version you are using is JPA 2.1 implementation.

          org.hibernate.jpa.boot.scan.spi.Scanner is the new interface in JPA 2.1 (in JPA 2.0 it was org.hibernate.ejb.packaging.Scanner of which org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner is an implementor). So either you would need to switch to JPA 2.1 complaint server (Wildfly) or use the new integration classses  from the project Jipijapa