8 Replies Latest reply: Jun 12, 2012 10:02 AM by Some Kid RSS

Hibernate 3.3.1 problems under JB 7

Some Kid Newbie

I'm working on the migration of a Seam 2.1.1/Hibernate 3.3.1 application from JB5.1 to JB7 and the main problems I have are related to Hibernate and the incompatibility between it's versions (prior and after 3.5)

I managed to deploy my application using the provided Hibernate module (ver.4.0.1) and for the most of the time it works fine. Until I try to save an entity in the DB. I have entities that have String ID columns and I get exception "Unknown integral data type for ids : java.lang.String" when an Id is generated via SequenceGenerator. I know this is a Hibernate issue but if anyone has any solutions for this -please share your experience.

I also tried using the original version of Hibernate (3.3.1) following the advices in the guide "How do I migrate my application from AS5/As6 to AS7". And I stumbled across a different problem: I get the exceptions below:

 

14:40:12,063 DEBUG [org.jboss.as.jpa] (MSC service thread 1-4) added (default provider) org.hibernate dependency to XXX.war (since 1 PU(s) didn't specify jboss.as.jpa.providerModule)
14:40:12,063 DEBUG [org.jboss.as.jpa] (MSC service thread 1-4) added org.hibernate.envers:main dependency to XXX.war
14:40:12,063 DEBUG [org.jboss.as.jpa] (MSC service thread 1-4) added org.hibernate:main dependency to XXX.war


      
14:40:13,048 TRACE [org.jboss.as.jpa] (MSC service thread 1-3) adding 'vfs:/C:/Apps/jboss-as-7.1.1.Final/bin/content/XXX.war/WEB-INF/lib/xmlpublic.jar/' to annotation index map
14:40:13,063 DEBUG [org.jboss.as.jpa] (MSC service thread 1-3) loaded persistence provider adapter org.jboss.as.jpa.hibernate:4
14:40:13,063 TRACE [org.jboss.as.jpa] (MSC service thread 1-3) returning global (module) Persistence Provider org.hibernate.ejb.HibernatePersistence
14:40:13,063 TRACE [org.jboss.as.jpa] (MSC service thread 1-3) lookup provider checking provider version (4.0.1.Final)


14:40:13,188 TRACE [org.jboss.as.jpa] (MSC service thread 1-3) added PersistenceUnitService for 'service jboss.persistenceunit."XXX.war#XXX"'.  PU is ready for injector action.
14:40:13,563 INFO  [org.jboss.as.jpa] (MSC service thread 1-6) JBAS011402: Starting Persistence Unit Service 'XXX.war#XXX'
14:40:13,673 INFO  [org.hibernate.annotations.common.Version] (MSC service thread 1-6) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
14:40:13,673 INFO  [org.hibernate.Version] (MSC service thread 1-6) HHH000412: Hibernate Core {4.0.1.Final}
14:40:13,688 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-6) HHH000206: hibernate.properties not found
14:40:13,688 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-6) HHH000021: Bytecode provider name : javassist
14:40:13,704 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-6) HHH000204: Processing PersistenceUnitInfo [
          name: XXX
          ...]

      

14:40:13,876 TRACE [org.jboss.as.jpa] (MSC service thread 1-6) getPackagesInJar found package package com.xxx.yyy.xxx.action
14:40:14,438 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-6) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
14:40:14,438 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jboss.persistenceunit."XXX.war#XXX": org.jboss.msc.service.StartException in service jboss.persistenceunit."xxx.war#xxx": Failed to start service
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_10-rc2]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_10-rc2]
          at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_10-rc2]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: XXX] Unable to build EntityManagerFactory
          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
          at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
          ... 3 more
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:187)
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150)
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
          at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:234)
          at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:91)
          at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
          at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
          at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270)
          at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266)
          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735)
          at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
          ... 9 more
Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider]
          at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:190)
          at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:112)
          at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:54)
          at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69)
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:177)
          ... 22 more
Caused by: java.lang.ClassCastException: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider cannot be cast to org.hibernate.service.jdbc.connections.spi.ConnectionProvider
          at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:187)
          ... 26 more

 

Here's my jboss-deployment-structure.xml file

 

<jboss-deployment-structure>
  <deployment>
    <exclusions> 
      <module name="javax.faces.api" slot="main"/>
      <module name="com.sun.jsf-impl" slot="main"/>    
      <module name="org.hibernate" slot="main"/>    
      <module name="org.hibernate.validator" slot="main" />   
    </exclusions>
    <dependencies>
      <module name="org.dom4j"/>
      <module name="org.apache.log4j"/>
      <module name="org.apache.commons.collections"/>
      <module name="javax.faces.api" slot="1.2"/>
      <module name="com.sun.jsf-impl" slot="1.2"/>
    </dependencies>
  </deployment>
</jboss-deployment-structure>


 

 

And here's my persistence.xml

 

<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
             version="1.0">
             
   <persistence-unit name="XXX" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:jboss/datasources/XXXDatasource</jta-data-source>
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
         <property name="hibernate.hbm2ddl.auto" value="validate"/>
         <property name="hibernate.show_sql" value="true"/>
         <property name="hibernate.format_sql" value="true"/>
         <property name="jboss.entity.manager.factory.jndi.name" value="java:/XXXEntityManagerFactory"/>


      </properties>
   </persistence-unit>
    
</persistence>

 

I have copied in WEb-INF/lib the following files (ver.3.3.1):

 

hibernate-core.jar

hibernate-annotations.jar

hibernate-commons-annotations.jar

hibernate-entitymanager.jar

hibernate-validator.jar

 

 

I can also see at the beginning of the log file that although I excluded Hibernate 4.0.1 from the deployment it's still being deployed.

 

Could anyone tell me what am I missing or doing wrong?

Thanks.