[jboss-user] [Datasource Configuration] - JBoss 5.0 and 5.1 MySql-Hibernate Dialect Class Cast error--works in JBoss 4.2.3
Chris Stepnitz
do-not-reply at jboss.com
Tue Jun 15 11:26:40 EDT 2010
Chris Stepnitz [http://community.jboss.org/people/cstepnitz] created the discussion
"JBoss 5.0 and 5.1 MySql-Hibernate Dialect Class Cast error--works in JBoss 4.2.3"
To view the discussion, visit: http://community.jboss.org/message/548056#548056
--------------------------------------------------------------
Hi,
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.
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"
I'm mystified. Any guesses? Details below.
*Stack Trace:*
08:32:31,453 INFO [Version] Hibernate Commons Annotations 3.1.0.GA
08:32:31,453 INFO [Version] Hibernate EntityManager 3.4.0.GA
08:32:31,500 INFO [Ejb3Configuration] Processing PersistenceUnitInfo [
name: MyPersistence
...]
08:32:31,546 WARN [Ejb3Configuration] Persistence provider caller does not impl
ement the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
08:32:31,625 INFO [HibernateSearchEventListenerRegister] Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
08:32:31,640 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
08:32:32,093 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=#MyPersistence state=Create
javax.persistence.PersistenceException: [PersistenceUnit: MyPersistence] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)
at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:301)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
[CUT HERE FOR LENGTH]
Caused by: org.hibernate.HibernateException: Could not instantiate dialect class
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:84)
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:66)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
... 61 more
Caused by: java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot be cast to org.hibernate.dialect.Dialect
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:78)
... 69 more
08:32:34,234 INFO [TomcatDeployment] deploy, ctxPath=/myCtx
08:33:03,250 INFO [[/myCtx]] Initializing log4j from [classpath:log4j.xml]
08:33:03,281 INFO [[/myCtx]] Initializing Spring root WebApplicationContext
*My Data Source:*
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>MyPersistence</jndi-name>
<jta-data-source>MyPersistence</jta-data-source>
<connection-url>jdbc:mysql://localhost:3306/myApp</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>FAKEUSER</user-name>
<password>FAKEPASSWORD</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<track-statements/>
<application-managed-security/>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
</local-tx-datasource>
</datasources>
*My Persistence.xml in my.war*
<persistence xmlns=" /java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit transaction-type="JTA">
<jta-data-source>java:/MyPersistence</jta-data-source>
</persistence-unit>
</persistence>
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/548056#548056]
Start a new discussion in Datasource Configuration at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100615/51eed0ed/attachment-0001.html
More information about the jboss-user
mailing list