1

I have one Hibernate project as CoreServices with all Hibernate configuration. I have imported the Project jar in my another project But I am getting

error Caused by: org.hibernate.HibernateException: No Session found for current thread

    <context:property-placeholder location="classpath:application.properties" />
    <context:annotation-config />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
</bean>
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan">
        <list>
            <value>****.******.model</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql:false}</prop>
            <prop key="hibernate.format_sql">${hibernate.format_sql:false}</prop>
        </props>
    </property>
</bean>
<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="persistenceExceptionTranslationPostProcessor"
    class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
void
  • 7,760
  • 3
  • 25
  • 43
Mohsin Khan
  • 90
  • 2
  • 11
  • I assume the relevant code is marked with '@Transaction' annotations, right? – Jens Schauder May 09 '15 at 05:47
  • possible a duplicate of : http://stackoverflow.com/questions/8846586/no-session-found-for-current-thread-spring-3-1-x-and-hibernate-4 – Spartan May 10 '15 at 01:42
  • Hi @JensSchauder Yes the code is marked with Transaction but only prblem is that it is a ltogether different project with all hibernate DAO and Services to access that dao. I have included the jar in my project but i am getting org.hibernate.HibernateException: No Session found for current thread – Mohsin Khan May 11 '15 at 14:39
  • I got the root cause. This is happening because of AOP class for logging. Does anybody have any Idea for this. – Mohsin Khan May 12 '15 at 13:34
  • Hi, When ever i am putting on my AOP logger class I am getting Caused by: org.hibernate.HibernateException: No Session found for current thread – Mohsin Khan May 12 '15 at 20:58

0 Answers0