17 Ekim 2013 Perşembe

Exception in thread "main" org.hibernate.HibernateException: No Session found for current thread hatası

Spring ve Hibernate i kullandığımda spring beanlerin konfigürasyonunu yaptığım dosyada eklemeyi unuttuğum "transactionManager" bean'i ve "<tx:annotation-driven/>" tagı sonucunda aldığım hata.


Sonuç olarak "transactionManager" bean'ini

     bean id="transactionManager"
          class="org.springframework.orm.hibernate4.HibernateTransactionManager"
          p:sessionFactory-ref="sessionFactory">
    </bean>

ve "<tx:annotation-driven/>" tagını

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:p="http://www.springframework.org/schema/p"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

    <context:component-scan base-package="com.springapp.mvc"/>

    <tx:annotation-driven/>
   .
   .
   .

ekledikten sonra hata almadan programımı çalıştırdım.



Hiç yorum yok:

Yorum Gönder