<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Hibernate 3.3.1 problems under JB 7
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/sam-user">Some Kid</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/message/737396#737396">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>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)</p><p>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<span style="color: #222222; font-family: arial, sans-serif; text-align: -webkit-auto; background-color: #ffffff; font-size: small;"> : 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.</span></p><p>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:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">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
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Here's my jboss-deployment-structure.xml file</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><jboss-deployment-structure></span>
  <span class="jive-xml-tag"><deployment></span>
    <span class="jive-xml-tag"><exclusions></span>
      <span class="jive-xml-tag"><module name="javax.faces.api" slot="main"/></span>
      <span class="jive-xml-tag"><module name="com.sun.jsf-impl" slot="main"/></span>   
      <span class="jive-xml-tag"><module name="org.hibernate" slot="main"/></span>   
      <span class="jive-xml-tag"><module name="org.hibernate.validator" slot="main" /></span>  
    <span class="jive-xml-tag"></exclusions></span>
    <span class="jive-xml-tag"><dependencies></span>
      <span class="jive-xml-tag"><module name="org.dom4j"/></span>
      <span class="jive-xml-tag"><module name="org.apache.log4j"/></span>
      <span class="jive-xml-tag"><module name="org.apache.commons.collections"/></span>
      <span class="jive-xml-tag"><module name="javax.faces.api" slot="1.2"/></span>
      <span class="jive-xml-tag"><module name="com.sun.jsf-impl" slot="1.2"/></span>
    <span class="jive-xml-tag"></dependencies></span>
  <span class="jive-xml-tag"></deployment></span>
<span class="jive-xml-tag"></jboss-deployment-structure></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>And here's my persistence.xml</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><span><persistence xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><span>"
             xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"
             xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><span> </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" target="_blank">http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd</a><span>"
             version="1.0"></span></span>
            
   <span class="jive-xml-tag"><persistence-unit name="XXX" transaction-type="JTA"></span>
      <span class="jive-xml-tag"><provider></span>org.hibernate.ejb.HibernatePersistence<span class="jive-xml-tag"></provider></span>
      <span class="jive-xml-tag"><jta-data-source></span>java:jboss/datasources/XXXDatasource<span class="jive-xml-tag"></jta-data-source></span>
      <span class="jive-xml-tag"><properties></span>
         <span class="jive-xml-tag"><property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/></span>
         <span class="jive-xml-tag"><property name="hibernate.hbm2ddl.auto" value="validate"/></span>
         <span class="jive-xml-tag"><property name="hibernate.show_sql" value="true"/></span>
         <span class="jive-xml-tag"><property name="hibernate.format_sql" value="true"/></span>
         <span class="jive-xml-tag"><property name="jboss.entity.manager.factory.jndi.name" value="java:/XXXEntityManagerFactory"/></span>
      <span class="jive-xml-tag"></properties></span>
   <span class="jive-xml-tag"></persistence-unit></span>
   
<span class="jive-xml-tag"></persistence></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I have copied in WEb-INF/lib the following files (ver.3.3.1):</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>hibernate-core.jar</p><p>hibernate-annotations.jar</p><p>hibernate-commons-annotations.jar</p><p>hibernate-entitymanager.jar</p><p>hibernate-validator.jar</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Could anyone tell me what am I missing or doing wrong?</p><p>Thanks.</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/737396#737396">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AS 7 Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>