Yes exactly. I want to put the management of session lifecycle and transaction and commit in a filter. I don't want to use the Tapestry-hibernate right now since I'm new in Hibernate and want to integrate it by myself first but ok, I'm going to follow your clue and take a look at the source of RequestFilter ;)
2007/12/13, Kristian Marinkovic <[EMAIL PROTECTED]>: > > hi michael, > > are you trying to implement OpenSessionInView by yourself? > tapestry-hibernate integration does it by default... you can take > a look at the source to see where you can apply filter the tapestry > way :) (see RequestFilter interface in Tapestry for example) > > g, > kris > > > > > "Michael Bernagou" <[EMAIL PROTECTED]> > 12.12.2007 13:59 > Bitte antworten an > "Tapestry users" <users@tapestry.apache.org> > > > An > "Tapestry users" <users@tapestry.apache.org> > Kopie > > Thema > Re: CustomFilter > > > > > > > In fact, I just noticed when I added the tapestry-core-5.0.6.jar in > [tomcat]/common/lib I still have an error but NOT on the same class. > So before it was on : > > java.lang.NoClassDefFoundError: org/apache/tapestry/TapestryFilter > > After put the tapestry-core jar in the lib of Tomcat : > > java.lang.NoClassDefFoundError: > org/apache/tapestry/ioc/services/SymbolProvider > > So I added the tapestry-ioc jar and now I have this one : > > java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory > > I imagine I could put all the lib at the server side, BUT, it's not how it > should work!! > > It seems the ClassLoader didn't load all the libs when apply the filter, > so > how to force the loading? Why TapestryFilter doesn't have the same problem > than my CustomFilter?? > > 2007/12/12, Michael Bernagou <[EMAIL PROTECTED]>: > > > > Hum, any idea? > > > > 2007/12/11, Michael Bernagou <[EMAIL PROTECTED]>: > > > > > > The error is generated by this line offcourse : > > > private TapestryFilter tapestryFilter = new TapestryFilter(); > > > > > > Still doesn't know why... > > > > > > 2007/12/11, Michael Bernagou < [EMAIL PROTECTED]>: > > > > > > > > Hi, > > > > > > > > I tried to creat emy own filter, a Hibernate filter in fact, like > that > > > > : > > > > > > > > [code] > > > > // here the imports... compilation ok > > > > public class HibernateFilter implements Filter { > > > > private TapestryFilter tapestryFilter = new TapestryFilter(); > > > > > > > > private static Log log = > LogFactory.getLog(HibernateFilter.class); > > > > > > > > public void init(FilterConfig filterConfig) throws > > > > ServletException { > > > > log.info("Servlet filter init, now opening/closing a Session > > > > for each request."); > > > > tapestryFilter.init(filterConfig); > > > > } > > > > > > > > public void doFilter(ServletRequest request, ServletResponse > > > > response, FilterChain chain) throws IOException, ServletException { > > > > > > > > try { > > > > HibernateUtil.beginTransaction(); > > > > chain.doFilter(request, response); > > > > HibernateUtil.commitTransaction(); > > > > > > > > } catch (RuntimeException e) { > > > > HibernateUtil.rollbackTransaction (); > > > > throw e; > > > > } catch (Exception e) { > > > > HibernateUtil.rollbackTransaction(); > > > > throw new ServletException(e); > > > > } finally { > > > > HibernateUtil.closeSession (); > > > > } > > > > > > > > tapestryFilter.doFilter(request, response, chain); > > > > } > > > > > > > > public void destroy() { > > > > tapestryFilter.destroy(); > > > > } > > > > } > > > > [/code] > > > > > > > > then I adapt my web.xml like that : > > > > > > > > [code] > > > > <filter> > > > > <filter-name>app</filter-name> > > > > <filter-class>org.hibernate.util.HibernateFilter > > > > </filter-class> > > > > </filter> > > > > <filter-mapping> > > > > <filter-name>app</filter-name> > > > > <url-pattern>/*</url-pattern> > > > > </filter-mapping> > > > > [/code] > > > > > > > > But I get that ERROR at runtime : > > > > > > > > [code] > > > > 11-Dec-2007 16:48:12 > org.apache.catalina.core.StandardContextfilterStart > > > > SEVERE: Exception starting filter app > > > > java.lang.NoClassDefFoundError: org/apache/tapestry/TapestryFilter > > > > [/code] > > > > > > > > TapestryFilter is not loaded by the ClassLoader. Why and how can I > do > > > > that? I tried to test by put the tapestry-core.jar directly in [ > > > > tomcat5.5]/common/lib without success. > > > > > > > > Any idea? > > > > > > > > Thanks! > > > > > > > > -- > > > > Michael Bernagou > > > > Java Developper > > > > > > > > > > > > > > > -- > > > Michael Bernagou > > > Java Developper > > > > > > > > > > -- > > Michael Bernagou > > Java Developper > > > > > -- > Michael Bernagou > Java Developper > > -- Michael Bernagou Java Developper