I got a method that uses hibernate to connect to DB and retrieve the data. The method works fine when executed as standalone java app. However when I try to deploy it on tomcat and invoke as a web service I get an error as below. My method is the first and the only place where DB connection is being established, i.e. I'm not defining any datasources within tomcat.
Code:
No Hibernate Session bound to thread, and configuration does not allow creation
of non-transactional one here
at
org.springframework.orm.hibernate3.LocalSessionFactoryBean$TransactionAwareInvocationHandler.invoke(LocalSessionFactoryBean.
My hibernate config file:
Code:
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="exposeTransactionAwareSessionFactory" value="true" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.statement_cache.size">10</prop>
<prop key="hibernate.c3p0.min_size">1</prop>
<prop key="hibernate.c3p0.max_size">10</prop>
<prop key="hibernate.connection.autocommit">false</prop>
<prop key="hibernate.default_schema">${mydbSchema}</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
</props>
</property>
</bean>
I'm using the following hibernate modules:
hibernate-annotations 3.4.0.GA
hibernate-core 3.3.1.GA
hibernate 3.2.6.ga
hibernate-commons-annotations 3.1.0.GA