Hi, Sir, thanks for providing the details.
 
but I can't fix the following deploy error when deploying my servlet to 
JBoss 5.1 
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(JpaPersistModule.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(JpaPersistModule.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 is are my annotation class for my persistence unit. since I use 
multiple persistence units, I also defined a  JpaUnitInstance class
 
@BindingAnnotation
@Retention(RetentionPolicy.RUNTIME)
public @interface CustomerJpaUnit 
{
}
 
class CustomerJpaUnitInstance<T extends Annotation> implements 
CustomerJpaUnit, Serializable 
{      
     private static final long serialVersionUID = -1986769782077028259L;
     private final  Class<T> value;        
     private CustomerJpaUnitInstance(Class<T> annotation) 
     {          
          this.value = annotation;      
     }        
 
     public Class<T> value()
     {          
          return this.value;      
     }        
 
        .....
}
 
 
here is my JPA module that extends PrivateModule:

public class CustomerDaoModule extends PrivateModule
{
      @Override
      protected void configure()
      {
            JpaPersistModule jpm = new JpaPersistModule("*rvng-customer*");
            jpm.properties(new Properties());       // some kinda bug 
without this
            install(jpm);
      
           
bindConstant().annotatedWith(CustomerJpaUnitInstance.of(CustomerJpaUnit.class)).to("rvng-customer");
 

          
 
bind(CustomerDao.class).annotatedWith(CustomerJpaUnit.class).to(CustomerDaoImpl.class);
           expose(CustomerDao.class).annotatedWith(CustomerJpaUnit.class);
      
          
 
bind(CustomerDaoInitializer.class).annotatedWith(CustomerJpaUnit.class).to(CustomerDaoInitializer.class);
          
expose(CustomerDaoInitializer.class).annotatedWith(CustomerJpaUnit.class);
      }
}
 
Similar, I have defined an annotation class and a private module with a 
different persistence unit. the pseudo code shown as below
public class RefereceDaoModule extends PrivateModule
{
       @Override
       protected void configure()
       {
           JpaPersistModule jpm = new JpaPersistModule("*rvng-referece*");
           jpm.properties(new Properties());       // some kinda bug without 
this
           install(jpm);
      
           bindConstant().annotatedWith( RefereceJpaUnitInstance.of( 
RefereceJpaUnit.class)).to("rvng-customer"); 
           bind( RefereceDao.class).annotatedWith( 
RefereceJpaUnit.class).to( RefereceDaoImpl.class);
           expose( RefereceDao.class).annotatedWith( RefereceJpaUnit.class);
      
           bind( RefereceDaoInitializer.class).annotatedWith( 
RefereceJpaUnit.class).to( RefereceDaoInitializer.class);
           expose( RefereceDaoInitializer.class).annotatedWith( 
RefereceJpaUnit.class);
      }
}

in my logic domain module, I invoke these two private modules:

public class CustomerDomainModule extends AbstractModule
{
      @Override
      protected void configure() 
      {
            install(new ReferenceDaoModule());
  
            install(new CustomerDaoModule())
         ......
      }
}

In my test servlet, I  inject the CustomerDomainModule, like
 
public class GuiceServletConfig extends GuiceServletContextListener
{
       @Override
       protected Injector getInjector() 
       {
              return Guice.createInjector(new ServletModule( ) 
              {
                   @Override
                   protected void configureServlets() 
                  {
                           install(new CustomerDomainModule());
                           filter("/*").through(PersistFilter.class); 
                           
serve("/customerHandler").with(CustomerHandler.class);
                  }
               });
       }
}
 
Could you please advise what I did wrong? I really appreciate your help.
 
-Alice

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-guice/-/dUhJZEpTVHFWNU1K.
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.

Reply via email to