I just came from my tiny pretty world of JavaSE / Guice and am currently discovering the container-portable path -EE6. After some problems with Glassfish3.1, I just switched to JBoss and now run into a problem that shouldn't be like that.
As an infrastructure support class, I am trying to create a common / DAO repository for any type of entity. Very simple, it may look like this.
public class Repository<E, K extends Serializable & Comparable<K>> { private final Instance<EntityManager> entityManagerInstance; protected final Class<E> getDomainObjectClass() { return domainObjectClass; } private final Class<E> domainObjectClass; protected final EntityManager getEntityManager() { return entityManagerInstance.get(); } @Inject public Repository(Instance<EntityManager> entityManageryProvider, Provider<E> domainObjectProvider) {
Now there may be a bean that does not require entity-specific capabilities, but simply a repository of a certain type of entity, for example (it can be a test one):
public class DomainObjectARepositoryTest{ @Inject Repository<DomainObjectA, PersistableUUID> domainObjectARepository; @Test public void testMitarbeitererstellung() { for (DomainObjectA a : domainObjectARepository.getAllEntities()) {
Unfortunatly Weld does not seem to like this generic injection. During deployment, I get the following error:
state=Create: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Repository<DomainObjectA , PersistableUUID>] with qualifiers [@Default] at injection point [[field] @Inject sompackage.DomainObjectARepositoryTest.domainObjectARepository]
Am I missing something or just forgot to introduce a generic injection? As far as I understand the general material, it is still erased after compilation, even until now it was so good in guice3.
Yours faithfully,
Avi
edit: found comment garvin king that this behavior is in the specification but not implemented in welding (staement was in June 2009)
dwegener
source share