I have Class in src/groovy . I want to use my service here . but error occurred "No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here ". i try to debug but not able to find . can you please help me that what is my mistake .
class ListenerSession implements HttpSessionListener { def transactionService = new TransactionService () public ListenerSession() { } public void sessionCreated(HttpSessionEvent sessionEvent){ } public void sessionDestroyed(HttpSessionEvent sessionEvent) { HttpSession session = sessionEvent.getSession(); User user=session["user"] if(user){ try{ java.util.Date date = session['loginDate'] transactionService.updateUserLastLogin(user,date) -----}catch (Exception e) { println e } code in service is:
def updateUserLastLogin(User user,Date date){ try{ User.withTransaction{ println "121212" user.lastLogin=date user.loginDuration=new Date().time - user?.lastLogin?.time def x=user.save() } }catch (Exception e) { println e } }
web.xmlfile? also, this should give you some advice: stackoverflow.com/questions/4088259/…