Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-22674

HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

    Details

      Description

      In a ServiceBuilder based portlet, obtaining hibernate session is failing in all method calls of *.service.persistence.*Util.java classes, where *PersistenceImpl is obtained like this :

      *Util.java
          public static *Persistence getPersistence() {
              if (_persistence == null) {
                  _persistence = (BidPersistence) PortletBeanLocatorUtil.locate(cz.instance.transl.service.ClpSerializer.getServletContextName(),
                          BidPersistence.class.getName());
      
                  ReferenceRegistry.registerReference(BidUtil.class, "_persistence");
              }
      
              return _persistence;
          }
      

      Whereas if *Persistence is obtained by BeanReferenceAnnotationBeanPostProcessor, it works :

       
          @BeanReference(type = *Persistence.class)
          protected *Persistence *Persistence;
      

      StackTrace:

      Caused by: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
      at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
      at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:687)
      at com.liferay.portal.dao.orm.hibernate.PortletSessionFactoryImpl.openSession(PortletSessionFactoryImpl.java:53)
      at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.openSession(BasePersistenceImpl.java:178)
      at cz.instance.transl.service.persistence.BidPersistenceImpl.findAll(BidPersistenceImpl.java:880)
      at cz.instance.transl.service.persistence.BidPersistenceImpl.findAll(BidPersistenceImpl.java:810)
      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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      at com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice.invoke(ShardPersistenceAdvice.java:52)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy527.findAll(Unknown Source)
      at cz.instance.transl.service.persistence.BidUtil.findAll(BidUtil.java:306)

      Steps to reproduce would be these
      1. create SB portlet from maven archetype
      2. build-services
      3. call com.example.project.service.persistence.Entity.countByOrder(someId);

      But it doesn't occur...Hence there must be something specific to my portlet, but I can't figure out what, after a few hours of searching for that...

      Might relate to LPS-17142

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                8 years, 41 weeks, 2 days ago

                Packages

                Version Package
                --Sprint 12/11
                6.1.0 CE RC1