I am not 100% sure but I think guice does not support the @Produces annotation. So far I only used @Provides
Also if you are using tomEE you already have a CDI container. What is your reason to use guice in such an environment. Don't missunderstand me. I prefer guice over CDI but why chose tomEE and then don't use its feature... Am 28. September 2016 19:36:28 MESZ, schrieb "Robério Cardoso Fernandes" <roberi...@gmail.com>: >I'm doing the integration tests with Apache OpenEJB (tomee). The bind >is >done when the container is started. > > > >Em quarta-feira, 28 de setembro de 2016 14:12:46 UTC-3, scl escreveu: >> >> Where do you bind the EntityManager? Is it bound just in time? At >runtime >> do you have a container or similar which provides the EntityManager? >> >> Am 28. September 2016 17:20:16 MESZ, schrieb "Robério Cardoso >Fernandes" < >> robe...@gmail.com <javascript:>>: >>> >>> Hi folks, >>> I'm doing the unit tests in my project, and I'm trying to use the >Google >>> Guice. My repository classes have your EntityManagers, and, in my >project, >>> to specify the persistence unit I have an annotation: >>> >>> @javax.inject.Qualifier >>> @java.lang.annotation.Retention(RUNTIME) >>> @java.lang.annotation.Target({FIELD, TYPE, METHOD}) >>> public @interface ConnectionDatabase { >>> } >>> >>> >>> In my repositories the entity managers are injected like this: >>> >>> public class MyRepository implements IMyRepository { >>> >>> @javax.inject.Inject >>> @ConnectionDatabase >>> private javax.persistence.EntityManager entityManager; >>> } >>> >>> >>> M ResourceProducer, like this: >>> >>> public class ResourceProducer { >>> >>> @javax.enterprise.inject.Produces >>> @Inject >>> @ConnectionDatabase >>> private javax.persistence.EntityManager entityManager; >>> } >>> >>> >>> My Module of Google Guice is like this: >>> >>> public class ModuleTest extends AbstractModule { >>> >>> @Override >>> public void configure() { >>> bind(new TypeLiteral<IMyRepository>() >{}).to(MyRepository.class); >>> } >>> } >>> >>> >>> I have a persistence.xml with a persistence unit called "TestPU". >>> >>> >>> In my unit tests (or cintegration tests), using the Google Guice, >the >>> EntityManager is not injected, and the following error is occurring: >>> No implementation for javax.persistence.EntityManager annotated with > >>> @ConnectionDatabase() was bound. >>> while locating javax.persistence.EntityManager annotated with >>> @ConnectionDatabase() >>> for field at MyRepository.entityManager(<the line>) >>> at ModuloTest.configure(<the line of the bind "bind(new >>> TypeLiteral<IMyRepository>() {}).to(MyRepository.class)">) >>> >>> >>> Someone here can help me, please? >>> >>> > >-- >You received this message because you are subscribed to the Google >Groups "google-guice" group. >To unsubscribe from this group and stop receiving emails from it, send >an email to google-guice+unsubscr...@googlegroups.com. >To post to this group, send email to google-guice@googlegroups.com. >Visit this group at https://groups.google.com/group/google-guice. >To view this discussion on the web visit >https://groups.google.com/d/msgid/google-guice/fc26fa51-d3c1-4f17-a4f5-cd7f72c6eade%40googlegroups.com. >For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+unsubscr...@googlegroups.com. To post to this group, send email to google-guice@googlegroups.com. Visit this group at https://groups.google.com/group/google-guice. To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/A2CDA87D-7E87-48C6-B232-FB55F3658F84%40gmx.ch. For more options, visit https://groups.google.com/d/optout.