The following Exception occurs when i inject the UserRepository Interface in to the controller:
EJB Invocation failed on component UserRepositoryMock for method public abstract java.util.List com.test.repository.IRepository.all(): javax.ejb.EJBTransactionRolledbackException: WFLYEE0042: Failed to construct component instance
I'm not sure, maybe the inheritance hierachy could be a problem:
IRepository is implemented by IUserRepository. Then I've an abstract class AbstractRepository that also implements IRepository. The UserRepositoryMock extends AbstractRepository and implements the IUserRepository Interface.
In Code:
@Singleton
@Alternative
public class UserRepositoryMock extends AbstractRepository<IUser> implements IUserRepository {
@EJB
private IUserFactory userFactory;
public UserRepositoryMock(){
userFactory.generateFirstUser()
}
}
AbstractRepository
@Singleton
public abstract class AbstractRepository<T extends IBO> implements IRepository<T> {
@Override
public List<T> all(){....}
}
IUserRepository:
public interface IUserRepository extends IRepository<IUser>{
...
}
Other injections working fine, any ideas?
I would suggest to change this:
public UserRepositoryMock(){
userFactory.generateFirstUser();
}
to something like:
@PostConstruct
public void setup() {
userFactory.generateFirstUser();
}