Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

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

$
0
0
Hello, everybody!
I'm beginner in Spring. I started project with Spring+JSF(PrimeFaces)+Hibernate.
Login page works fine. But after that, when page redirecting to index.jsf

Code:


<!-- index.jsf -->
<p:panel id="mainPanel">
    <h:outputText value="#{loginBean.currentUser.email}"/>
</p:panel>

get folowing erros:

Code:

Caused by: org.hibernate.HibernateException: No Session found for current thread
        at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97)
        at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:988)
        at com.food.dao.impl.BaseDAOImpl.ht(BaseDAOImpl.java:35)
        at com.food.dao.impl.UserDAOImpl.getUserByEmail(UserDAOImpl.java:47)
        at com.food.webapp.beans.LoginBean.init(LoginBean.java:142)
        at com.food.webapp.beans.LoginBean.getCurrentUser(LoginBean.java:70)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
        at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:173)
        at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:200)
        at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
        at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
        at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:106)
        ... 76 more

What do I wrong? Please, help me anyone...
applicationContext-business.xml
Code:

<tx:annotation-driven transaction-manager="transactionManager" />
    <bean id="transactionManager1"
          class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <qualifier value="postgresT" />
        <property name="sessionFactory" ref="sessionFactoryPostgres" />
    </bean>
<bean id="dataSourcePostgres"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${db.driverClassName}"
          p:url="${db.url}"
          p:username="${db.username}"
          p:password="${db.password}" />
   
    <!-- Настройки фабрики сессий Хибернейта -->
    <bean id="sessionFactoryPostgres"
          class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSourcePostgres" />
        <property name="packagesToScan">
            <list>
                <value>com.food.model</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="...">...</prop>
            </props>
        </property>
    </bean>

Please, help me...

Viewing all articles
Browse latest Browse all 297

Trending Articles