Reading the javadocs for PersistFilter I cannot understand this sentece: "For multiple providers, you should register this filter once per provider, inside a private module for each persist module installed (this must be the same private module where the specific persist module is itself installed)."
Can anyone help me? On 3 Giu, 17:43, aldoz <[email protected]> wrote: > Hello, > > I'm evaluating Guice for our new projects and I like it. To do this I > set up a test env to work with tomcat+guice+struts2+openjpa+derby. > > Now I'm triyng to figure how to work with multiple database and I get > the following error: > > 1) Unable to create binding for > com.google.inject.persist.PersistService. It was already configured on > one or more child injectors or private modules > bound at > com.google.inject.persist.jpa.JpaPersistModule.configurePersistence(JpaPers > istModule.java: > 69) > If it was in a PrivateModule, did you forget to expose the binding? > while locating com.google.inject.persist.PersistService > for parameter 1 at > com.google.inject.persist.PersistFilter.<init>(PersistFilter.java:71) > while locating com.google.inject.persist.PersistFilter > > 2) Unable to create binding for com.google.inject.persist.UnitOfWork. > It was already configured on one or more child injectors or private > modules > bound at > com.google.inject.persist.jpa.JpaPersistModule.configurePersistence(JpaPers > istModule.java: > 70) > If it was in a PrivateModule, did you forget to expose the binding? > while locating com.google.inject.persist.UnitOfWork > for parameter 0 at > com.google.inject.persist.PersistFilter.<init>(PersistFilter.java:71) > while locating com.google.inject.persist.PersistFilter > > Here are modules I wrote: > > public class Struts2DemoListener extends GuiceServletContextListener { > public Injector getInjector() { > return Guice.createInjector(new Struts2GuicePluginModule(), > // the servlet conf for struts2 > new MyServletModule(), > // application specific module > new PrivateModule() { > protected void configure() { > install(new JpaUserRegistryServiceModule()); > expose(UserRegistryService.class); > } > }, new PrivateModule() { > protected void configure() { > install(new JpaAccessLogServiceModule()); > expose(AccessLogService.class); > } > }); > } > > class MyServletModule extends ServletModule { > @Override > protected void configureServlets() { > // Struts 2 setup > > bind(StrutsPrepareAndExecuteFilter.class).in(Singleton.class); > filter("/*").through(PersistFilter.class); > // filter("/*").through(AccessLogFilter.class); > > filter("/*").through(StrutsPrepareAndExecuteFilter.class, > strutsParams); > } > } > > } > > public class JpaUserRegistryServiceModule extends AbstractModule { > protected void configure() { > install(new JpaPersistModule("g2011")); > > bind(UserRegistryService.class).to(GuicedJpaUserRegistryService.class); > } > > } > > public class JpaAccessLogServiceModule extends AbstractModule { > protected void configure() { > install(new JpaPersistModule("accessLog")); > > bind(AccessLogService.class).to(GuicedJpaAccessLogService.class); > } > > > > > > > > } -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
