-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: HibernateException with JUnit
PostPosted: Mon Jun 12, 2006 10:03 am 
Newbie

Joined: Sat Jun 10, 2006 9:35 am
Posts: 3
Hello Everybody

I wrote a little Junit test case that does the following

public class MyTest extends TestCase {

public void testExec() {
try
{
Class dialectClass = Class.forName("org.hibernate.dialect.MySQLInnoDBDialect");
MySQLInnoDBDialect dialect = (MySQLInnoDBDialect)dialectClass.newInstance();

SessionFactory sessionFactory = new Configuration()
.configure("hibernate.cfg.xml")
.buildSessionFactory();
....
}
catch(Exception ex)
{
}
}


When the program try to configure the hibernate SessionFactory gets a HibernateException with a detailMessage = "Could not instantiate dialect class". The dialect class is MySQLInnoDBDialect and I'm sure it is in the classpath (the first two rows of the program have no problems).
If I try to run the example as a standalone main, no problems, all ok.

Thank you in advance for all hints

Loris


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 12, 2006 10:37 am 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
would you mind posting the whole stack trace!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 3:22 am 
Newbie

Joined: Sat Jun 10, 2006 9:35 am
Posts: 3
Here it is.


org.hibernate.HibernateException: Could not instantiate dialect class
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:84)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:378)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at command.shopping.test.WebOpenShoppingCmdTest.testExec(WebOpenShoppingCmdTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.swingui.TestRunner$16.run(TestRunner.java:623)
Caused by: java.lang.ClassCastException: org.hibernate.dialect.MySQLInnoDBDialect
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:78)
... 21 more


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.