Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.5
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
[java] org.hibernate.HibernateException: Could not find datasource
[java] at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:48)
[java] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
[java] at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:313)
[java] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:112)
[java] at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1509)
[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
[java] at ami.server.ejb.HibernateUtil.<clinit>(HibernateUtil.java:37)
[java] at ami.server.datamart.billing.AggregationTestCase.testDailyAggregation(AggregationTestCase.java:89)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at junit.framework.TestCase.runTest(TestCase.java:154)
[java] at junit.framework.TestCase.runBare(TestCase.java:127)
[java] at junit.framework.TestResult$1.protect(TestResult.java:106)
[java] at junit.framework.TestResult.runProtected(TestResult.java:124)
[java] at junit.framework.TestResult.run(TestResult.java:109)
[java] at junit.framework.TestCase.run(TestCase.java:118)
[java] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[java] at junit.framework.TestSuite.run(TestSuite.java:203)
[java] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[java] at junit.framework.TestSuite.run(TestSuite.java:203)
[java] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[java] at junit.framework.TestSuite.run(TestSuite.java:203)
[java] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[java] at junit.framework.TestSuite.run(TestSuite.java:203)
[java] at junit.textui.TestRunner.doRun(TestRunner.java:116)
[java] at junit.textui.TestRunner.start(TestRunner.java:172)
[java] at junit.textui.TestRunner.main(TestRunner.java:138)
[java] Caused by: javax.naming.NameNotFoundException: MySqlDS not bound
Name and version of the database you are using:
MySQL 4.1.14
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
I am attempting to access a SessionFactory through JNDI within a standalone J2SE class, and I keep getting the exception "org.hibernate.HibernateException: Could not find datasource . . . Caused by: javax.naming.NameNotFoundException: MySqlDS not bound"
Based on the documentation I have read, I am of the understanding that the properties from the default hibernate.cfg.xml file(which I am using) are loaded into the context at the time of the "buildSessionFactory();" call. However, I am still getting the "not bound" error. I don't understand why this exception would be thrown at the point where the properties are being loaded to the context. Am I just missing something simple here?
Here is the code from HibernateUtil.java:
<b>static {
try { configuration = new Configuration(); sessionFactory = configuration.configure("hibernate.cfg.xml").buildSessionFactory(); parallelConfiguration = new Configuration();
parallelSessionFactory = parallelConfiguration.configure("hibernateParallel.cfg.xml").buildSessionFactory();
} catch (Throwable ex) {
// We have to catch Throwable, otherwise we will miss
// NoClassDefFoundError and other subclasses of Error
log.error("Building SessionFactory failed.", ex);
throw new ExceptionInInitializerError(ex);
}
</b>
I have a JBoss instance running, but I want to access the SessionFactory from outside the app-server JNDI tree. This should be possible seeing that the InitialContext may span multiple JVMs.
Is it even possible to access the SessionFactory by way of JNDI outside of the web-ejb container?
Thanks in advance!
Mark