I have the following Producer class:
@RequestScoped
public class MsmEntityManagerProducer {
@PersistenceContext(unitName = MSM)
private EntityManager entityManager;
private static final String MSM = "MSM";
@Produces
@MsmQualifier
public EntityManager getMsmEntityManager() {
return entityManager;
}
}
which is used in a class that should execute on JBoss startup:
@ApplicationScoped
public class StartupActiviti {
@Inject
@MsmQualifier
private EntityManager entityManager;
public void init(@Observes @Initialized(ApplicationScoped.class) Object startupObject){
}
@PostConstruct
public void updateTasks() {
log.debug("start StartupActiviti");
}
}
However, the updateTasks() method is not called and silently ignored without any exception. Well, I have found a solution (either change @RequestScoped to @Dependent or retrieve the EntityManager within the @PostConstruct method instead of injection, but does anybody has an explanation for this weird behaviour? Such kind of failures are really hard to track down if no exception is raised