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