(Sorry I reordered your post, and keep the discussion on users list please).
On Mon, Jan 10, 2011 at 10:39 AM, Rich M <rich...@moremagic.com> wrote: > I'm a bit late catching up on list reading, but I saw this message you had > written and it looked like something I've been interested in doing with my > Hibernate setup for a while now. I more or less cut and paste that code into > I get an exception as follows: > > Caused by: java.lang.RuntimeException: Exception constructing service > 'HibernateSessionSource': Error invoking service builder method > org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionSource(Logger, > List, RegistryShutdownHub) (at HibernateCoreModule.java:123) (for service > 'HibernateSessionSource'): /hibernate.cfg.xml not found > The worrisome part is that it is looking for /hibernate.cfg.xml, rather than > /hibernate-production.cfg.xml or /hibernate-test.cfg.xml, leading me to > believe the contribute method is either never executed, or not executed > early enough. > Any thoughts? (Actually there's no point even injecting the DefaultHibernateConfigurer in, that was a leftover from old implementation). What you are missing is (in contributeApplicationDefaults): configuration.add(HibernateSymbols.DEFAULT_CONFIGURATION, "false"); Apologies for leaving it out, I'm sure it's documented *some*where... Kalle > On 01/03/2011 02:07 PM, Kalle Korhonen wrote: >> >> Probably lots of way to do that, but I typically use code similar to this: >> public void >> contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer> >> configurer, >> �...@injectservice("DefaultHibernateConfigurer") >> HibernateConfigurer >> defaultHibernateConfigurer) { >> >> class RunModeDependentHibernateConfigurer implements >> HibernateConfigurer { >> >> public void >> configure(org.hibernate.cfg.Configuration configuration) { >> if (productionMode || >> "true".equals(System.getProperty(Symbols.FORCE_PERSISTENT_DB))) >> configuration >> >> .configure("/hibernate-production.cfg.xml"); >> else >> configuration.configure("/hibernate-test.cfg.xml"); >> } >> } >> ; >> configurer.add(productionMode == true ? "production" : >> "test", new >> RunModeDependentHibernateConfigurer(), "before:*"); >> } >> >> Even if you are not contributing custom configurers, you could just >> inject the services you need and do your stuff with them within >> contributeHibernateSessionSource(). >> >> Kalle --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org