Hello all, I have a dispatcher service in my application to control the user access to pages they are not permitted to, or need to log in to do it. Besides, it does an insert into the DB to record the user's movements into the system, but just in case of success. It does well when we use the old way to access the database (ResultSet, Statements and so on...)
Trying to move to tapestry-hibernate, we have to do this to inject the hibernate session into the dispatcher service: AccessController.java: ======================================= /* hibernate session */ private Session _hibernateSession; public AccessController(ApplicationStateManager asm, Session hibernateSession) { this._asm = asm; this._hibernateSession = hibernateSession; } ... @CommitAfter public boolean dispatch(Request request, Response response) throws IOException { ... if (canAccess) { // Log do acesso. this.doLog(request, visit, hibernateSession); } ... } But when we try to persist the entity into the DB, it fails because the annotation @CommitAfter has no effect here (I suppose). I tried to start and commit a transaction manually and it did well, but when tapestry-hibernate tried to do another query, it fails and gives the following exception: [WARN] TapestryIOCModule.PerthreadManager Error invoking listener org.apache.tapestry5.internal.hibernate.hibernatesessionmanageri...@fa1b2d: Transaction not successfully started org.hibernate.TransactionException: Transaction not successfully started at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:183) at org.apache.tapestry5.internal.hibernate.HibernateSessionManagerImpl.threadDidCleanup(HibernateSessionManagerImpl.java:65) at org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl.cleanup(PerthreadManagerImpl.java:86) at org.apache.tapestry5.ioc.internal.RegistryImpl.cleanupThread(RegistryImpl.java:329) at org.apache.tapestry5.ioc.internal.RegistryWrapper.cleanupThread(RegistryWrapper.java:36) at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:185) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821) at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568) at org.mortbay.http.HttpContext.handle(HttpContext.java:1530) at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633) at org.mortbay.http.HttpContext.handle(HttpContext.java:1482) at org.mortbay.http.HttpServer.service(HttpServer.java:909) at org.mortbay.http.HttpConnection.service(HttpConnection.java:820) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986) at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245) at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534) anyone has any clue on how I can do this in a better way? Thanks in advance! -- Atenciosamente, Marcelo Lotif Programador Java e Tapestry FIEC - Federação das Indústrias do Estado do Ceará (85) 3421-5910