> > I don't have a solution for you, but it's a similar problem to trying to > > use the HibernateTemplate outside of a web-app. I have some command- > line > > tools that look like: > > > > .... > > this.session = > > SessionFactoryUtils.getSession(sessionFactory, true); > > > > TransactionSynchronizationManager.bindResource(sessionFactory, new > > SessionHolder(session)); > > > The invocation of bindResource fails with: > java.lang.IllegalStateException: Already value > [EMAIL PROTECTED] for key > [EMAIL PROTECTED] bound to thread [main] > > Jesper
I tend to be too brief. This was intended only as an avenue of investigation. The Spring Open Session In View Filter for Hibernate has similar lines to what I wrote above. Check out the source. When you try to use DAO's outside of a webapp, where you don't have the OSIV filter setting up transaction plumbing for you, you need to do it manually. I had a lot of grief using common configuration between a web app and supporting (command-line) tools until I figured that out. In your case, I assume the OSIV filter is bypassed when testing so that setup and cleanup is not done. I am *speculating* that if you move the OSIV from web.xml/servlet container level to one integrated into the internal Tapestry pipeline (as suggested in my other followup), your problem may go away. Honestly, I don't know. It seems reasonable but I don't know enough about the internals of tapestry-ioc. Take a look at the tapestry5-acegi code. Acegi uses Spring and tapestry5-acegi moves the configuration, including stuff that is normally configured in web.xml, into AppModule. It involved re-writing filters that used to be wired in through web.xml configuration to be suitable for wiring in through tapestry-ioc. Here is a little snippet from tapestry5-acegis's SecurityModule that may pique your curiosity: public static HttpServletRequestFilter buildHttpSessionContextIntegrationFilter() throws Exception { HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter(); filter.setContext(SecurityContextImpl.class); filter.setAllowSessionCreation(true); filter.setForceEagerSessionCreation(false); filter.afterPropertiesSet(); return new HttpServletRequestFilterWrapper(filter); } Or, I suppose you can give up on Spring and go for tapestry-hibernate :-) Jon --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]