title: Hibernate error in Liferay
body: <p>I am using liferay and here are my classes and methods in them:</p>
  
  
  
  <p><strong><code>EmployeeLocalServiceImpl.java</code></strong></p>
  
  <pre class="lang-java prettyprint-override"><code>public class EmployeeLocalServiceImpl extends EmployeeLocalServiceBaseImpl {
      /*
       * NOTE FOR DEVELOPERS:
       *
       * Never reference this interface directly. Always use {@link com.mallyas.corpserver.emco.mis.service.EmployeeLocalServiceUtil} to access the employee local service.
       */
  
      public List getEmployee() throws PortalException, SystemException, RemoteException {
  
          return EmployeeFinderUtil.getEmployee();
      }
   ...
  }
  </code></pre>
  
  <p><strong><code>EmployeeFinderImpl.java</code></strong></p>
  
  <pre class="lang-java prettyprint-override"><code>public class EmployeeFinderImpl extends BasePersistenceImpl&lt;Employee&gt; implements EmployeeFinder {
  
      // the name of the query
      public static String GET_EMPLOYEE = "getemployee";
  
      // the method which will be called from the ServiceImpl class
  
      public List&lt;Employee&gt; getEmployee() throws SystemException {
  
          Session session = null;
          try {
              // open a new hibernate session
              session = openSession();
  
  
              String fetchEmpsqlquery = CustomSQLUtil.get(GET_EMPLOYEE);
  
              // create a SQLQuery object
              SQLQuery empqueryObj = session.createSQLQuery(fetchEmpsqlquery);
  
              // replace the "Book" in the query string with the fully qualified java class
              // this has to be the hibernate table name
              empqueryObj.addEntity("Employee", EmployeeImpl.class);
  
  
              // Get query position instance
              QueryPos qPos = QueryPos.getInstance(empqueryObj);
  
              // fill in the "?" value of the custom query
              // this is same like forming a prepared statement
              //qPos.add(pattern);
  
              // execute the query and return a list from the db
              return (List&lt;Employee&gt;)empqueryObj.list();
  
              /*
              // use this block if you want to return the no. of rows (count)
  
              int rows = 0;
  
              Iterator&lt;Long&gt; itr = q.list().iterator();
  
              if (itr.hasNext()) { Long count = itr.next();
  
              if (count != null) { rows = count.intValue(); } }
  
              return rows;
              */
          } catch (Exception e) {
              throw new SystemException(e);
          } finally {
              closeSession(session);
          }
      }
  
      ...
  
  }
  </code></pre>
  
  <p><strong><code>EmployeeFinder.java</code></strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Transactional
  public interface EmployeeFinder {
  
      public java.util.List&lt;com.mallyas.corpserver.emco.mis.model.Employee&gt; getEmployee()
          throws com.liferay.portal.kernel.exception.SystemException;
  }
  </code></pre>
  
  <p><strong><code>EmployeeFinderUtil.java</code></strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Transactional
  public class EmployeeFinderUtil {
  
      public static java.util.List&lt;com.mallyas.corpserver.emco.mis.model.Employee&gt; getEmployee()
          throws com.liferay.portal.kernel.exception.SystemException {
          return getFinder().getEmployee();
      }
  
      public static EmployeeFinder getFinder() {
          if (_finder == null) {
              _finder = (EmployeeFinder)PortletBeanLocatorUtil.locate(com.mallyas.corpserver.emco.mis.service.ClpSerializer.getServletContextName(),
                      EmployeeFinder.class.getName());
  
              ReferenceRegistry.registerReference(EmployeeFinderUtil.class,
                  "_finder");
          }
  
          return _finder;
      }
  
      public void setFinder(EmployeeFinder finder) {
          _finder = finder;
  
          ReferenceRegistry.registerReference(EmployeeFinderUtil.class, "_finder");
      }
  
      private static EmployeeFinder _finder;
  </code></pre>
  
  <p>I get the following error when I run this application:</p>
  
  <pre class="lang-java prettyprint-override"><code>ERROR [http-bio-8080-exec-9][render_portlet_jsp:154] com.liferay.portal.kernel.exception.SystemException: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
      at com.mallyas.corpserver.emco.mis.service.persistence.EmployeeFinderImpl.getEmployee(EmployeeFinderImpl.java:69)
      at com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice.invoke(ShardPersistenceAdvice.java:52)
      at com.mallyas.corpserver.emco.mis.service.persistence.EmployeeFinderUtil.getEmployee(EmployeeFinderUtil.java:29)
      at com.mallyas.corpserver.emco.mis.service.impl.EmployeeLocalServiceImpl.getEmployee(EmployeeLocalServiceImpl.java:61)
      at org.apache.jsp.admin.displayData.dbcheck_jsp._jspService(dbcheck_jsp.java:172)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
      at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
      at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
      at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
  </code></pre>
  
  <p>What could possibly be wrong?
  I have included @Transactional in each of the above classes, I also tried removing @Transactional from all the classes but I still get the same error..</p>