Hibernate version:3.2.6
The cfg file looks like this
<hibernate-configuration>
<session-factory name="xxxdb">
<property name="hibernate.connection.provider_class">xxx.ism.core.hibernate.XXXConnectionProvider</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">true</property>
<property name="current_session_context_class">thread</property>
</session-factory>
</hibernate-configuration>
Problem
We are running our application in a non-managed environment, therefore we are not using JNDI.
In order to get a connection, we are using a custom connection provider which provides a connection object from an existing connection pool.
Our application runs fine. We are able to execute queries and get the result. However we noticed that during the process of building the session factory, we get the exception given below. Despite this the application runs without a problem. If we do not provide a name for the session factory, we do not get this exception.
(<session-factory> ...... </session-factory> )
Does this mean that providing a name to a session factory is possible only while using JNDI? We would like to provide a name to the session factory as we will be connecting to multiple databases in our application. How do we go about resolving this issue? Thanks in advance.
Full stack trace of any exception that occurs:
We get the following exception -
2008-09-03 11:21:53,250 DEBUG [main] (SessionFactoryObjectFactory.java:39) - initializing class SessionFactoryObjectFactory
2008-09-03 11:21:53,250 DEBUG [main] (SessionFactoryObjectFactory.java:76) - registered: 2bc66f711c2972f7011c2972fac20000 (emandb)
2008-09-03 11:21:53,250 INFO [main] (SessionFactoryObjectFactory.java:86) - Factory name: xxxdb
2008-09-03 11:21:53,250 INFO [main] (NamingHelper.java:26) - JNDI InitialContext properties:{}
2008-09-03 11:21:53,265 DEBUG [main] (NamingHelper.java:48) - binding: xxxdb
2008-09-03 11:21:53,265 WARN [main] (SessionFactoryObjectFactory.java:98) - Could not bind factory to JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getNameParser(Unknown Source)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:306)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at eman.ism.core.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:47)
at eman.ism.eue.db.service.BaseDBService.startOperation(BaseDBService.java:44)
at eman.ism.eue.db.service.TestDBService.get15MinsTestTrend(TestDBService.java:46)
at eman.ism.eue.db.service.TestDBServiceTest.testGet15MinsTestTrend(TestDBServiceTest.java:53)
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 org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
2008-09-03 11:21:53,265 DEBUG [main] (SessionFactoryImpl.java:308) - instantiated session factory
|