3 Replies Latest reply on May 28, 2014 12:46 PM by Ricardo Vila Branched to a new discussion.

    Migrating from JBoss AS 7.1.1 to EAP 6.2 causes spring-defined entityManagerFactory to fail when loading

    Ricardo Vila Newbie

      I'm developing an application using JPA 2.1 with spring 4.0.2. Jboss server provides a JNDI Datasource.

      I've defined this entityManager in services.xml in order to avoid the use of a persistence.xml file:

       

        <jee:jndi-lookup id="projectDataSourceTaget" jndi-name="${jndi.datasourceName}"

          expected-type="javax.sql.DataSource" />

       

      <bean id="entityManagerFactory"

          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"

          depends-on="flyway">

          <property name="jpaVendorAdapter">

            <bean

              class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />

          </property>

          <property name="packagesToScan" value="com.xxx" />

          <property name="persistenceUnitName" value="projectEntityManager" />

          <property name="jtaDataSource" ref="projectDataSourceTaget" />

          <property name="jpaProperties">

            <props>

              <prop key="hibernate.transaction.manager_lookup_class">

                org.hibernate.transaction.JBossTransactionManagerLookup

              </prop>

              <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>

              <!-- validate | update | create | create-drop -->

              <prop key="hibernate.hbm2ddl.auto">validate</prop>

              <prop key="hibernate.show_sql">true</prop>

              <prop key="hibernate.format_sql">false</prop>

              <prop key="org.hibernate.envers.use_revision_entity_with_native_id">false</prop>

              <prop key="javax.persistence.transactionType">JTA</prop>

            </props>

          </property>

        </bean>

      Althought this worked fine in Jboss 7.11 when changing to EAP 6.2 it fails to initialize the service:

       

      17:27:17,061 WARN  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (ServerService Thread Pool -- 48) HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections

      17:27:17,079 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 48) MSC000001: Failed to start service jboss.persistenceunit."Project.war#Project": org.jboss.msc.service.StartException in service jboss.persistenceunit."Project.war#Project": javax.persistence.PersistenceException: [PersistenceUnit: Project] Unable to build EntityManagerFactory

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_60-ea]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60-ea]

          at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_60-ea]

          at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar:2.1.1.Final-redhat-1]

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: GaIA] Unable to build EntityManagerFactory

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)

          at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          ... 4 more

      Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set

          at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:98)

          at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:68)

          at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:174)

          at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:76)

          at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:160)

          at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:132)

          at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1822)

          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1780)

          at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)

          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)

          ... 9 more