<!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="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">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;">
JBoss 5.0 and 5.1 MySql-Hibernate Dialect Class Cast error--works in JBoss 4.2.3
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/cstepnitz">Chris Stepnitz</a> in <i>Datasource Configuration</i> - <a href="http://community.jboss.org/message/548056#548056">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Hi,</p><p><br/>I'm trying to migrate my application to JBoss 5.1 or  JBoss 5.0.1 from JBoss 4.2.3, and I'm having some issues with the hibernate-to-mysql database  connection.  Both new versions of JBoss give me the same  error, while the same configuration works in JBoss 4.2.3.</p><p><br/>In short, I've successfully set up a data source  connection and jndi name for my war to a local mysql database.  My app itself uses hibernate to  'talk' to the database, and on deployment I get a ClassCast exception stating that  the default MySql dialect doesn't extend the right class (but it does!).   "Caused by: java.lang.ClassCastException:  org.hibernate.dialect.MySQLDialect  cannot be cast to  org.hibernate.dialect.Dialect"</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I'm mystified.  Any guesses?  Details  below.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><br/><strong>Stack Trace:</strong></p><p><br/>08:32:31,453 INFO  [Version] Hibernate Commons  Annotations 3.1.0.GA<br/>08:32:31,453 INFO  [Version] Hibernate EntityManager  3.4.0.GA<br/>08:32:31,500 INFO  [Ejb3Configuration] Processing  PersistenceUnitInfo [<br/>        name: MyPersistence<br/>         ...]<br/>08:32:31,546 WARN  [Ejb3Configuration] Persistence provider caller does  not impl<br/>ement the EJB3 spec correctly.  PersistenceUnitInfo.getNewTempClassLoader() is null.<br/>08:32:31,625 INFO   [HibernateSearchEventListenerRegister] Unable to find  org.hibernate.search.event.FullTextIndexEventListener on the classpath.  Hibernate Search is not enabled.<br/>08:32:31,640 INFO   [InjectedDataSourceConnectionProvider] Using provided datasource<br/>08:32:32,093  ERROR [AbstractKernelController] Error installing to Start:  name=persistence.unit:unitName=#MyPersistence  state=Create<br/>javax.persistence.PersistenceException: [PersistenceUnit:  MyPersistence] Unable to build EntityManagerFactory<br/>        at  org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)<br/>         at  org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)<br/>         at  org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:301)<br/>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br/>        at  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br/>         at  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br/>         at java.lang.reflect.Method.invoke(Method.java:597)<br/>        at  org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)<br/>         at  org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)<br/>         at  org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)<br/>         at  org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)<br/>         at  org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)<br/>         at  org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)<br/>         at  org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)<br/>         at  org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)<br/>         at  org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)<br/>         at  org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)<br/>         at  org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)<br/>         at  org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)<br/>         at  org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)<br/>         at  org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)<br/>         at  org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)<br/>         at  org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)<br/> <br/>         [CUT HERE FOR LENGTH]<br/> <br/>Caused by: org.hibernate.HibernateException: Could  not instantiate dialect class<br/>        at  org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:84)<br/>         at  org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:66)<br/>         at  org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)<br/>         at  org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)<br/>         at  org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)<br/>         at  org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)<br/>         at  org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)<br/>         at  org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)<br/>         at  org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)<br/>         ... 61 more<br/>Caused by: java.lang.ClassCastException:  org.hibernate.dialect.MySQLDialect cannot be cast to  org.hibernate.dialect.Dialect<br/>        at  org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:78)<br/>         ... 69 more<br/>        08:32:34,234 INFO  [TomcatDeployment] deploy,  ctxPath=/myCtx</p><p>08:33:03,250 INFO  [[/myCtx]] Initializing log4j from  [classpath:log4j.xml]<br/>08:33:03,281 INFO  [[/myCtx]] Initializing Spring root  WebApplicationContext</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong>My Data Source:</strong></p><p><?xml version="1.0"  encoding="UTF-8"?></p><p><datasources></p><p>   <local-tx-datasource><br/>       <jndi-name>MyPersistence</jndi-name><br/>       <jta-data-source>MyPersistence</jta-data-source></p><p>       <connection-url>jdbc:mysql://localhost:3306/myApp</connection-url></p><p>       <driver-class>com.mysql.jdbc.Driver</driver-class></p><p>       <user-name>FAKEUSER</user-name><br/>       <password>FAKEPASSWORD</password></p><p>       <min-pool-size>5</min-pool-size></p><p>       <max-pool-size>20</max-pool-size><br/>       <idle-timeout-minutes>0</idle-timeout-minutes></p><p>      <track-statements/></p><p>      <application-managed-security/>  </p><p>       <prepared-statement-cache-size>32</prepared-statement-cache-size></p><p>    </local-tx-datasource><br/></datasources></p><p><br/><strong>My Persistence.xml in my.war</strong></p><p><persistence xmlns="<a class="jive-link-external-small" href="/java.sun.com/xml/ns/persistence">http://java.sun.com/xml/ns/persistence</a>"  version="1.0"><br/>     <persistence-unit  transaction-type="JTA"><br/>          <jta-data-source>java:/MyPersistence</jta-data-source>  <br/>      </persistence-unit><br/></persistence></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/548056#548056">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Datasource Configuration at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>