Hello,

I'm getting:

Caused by: java.lang.RuntimeException:
org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active
contexts for scope type javax.enterprise.context.RequestScoped

On bootstrap:

@ApplicationScoped
public class BootConfig
{
    @Inject
    private Logger logger;

    @Inject
    private ConfigRepo configRepo ;


    public void init(@Observes @Initialized(ApplicationScoped.class) Object
init){
          *//There's no Request Scope here*
          Config c = configRepo.findByKey("my.key");
          //....
    }
}

@Repository
public abstract class ConfigRepo extends AbstractEntityRepository<Config,
Long>
{

    private static final QConfig c= QConfig.config;

    public Stop findByKey(final String key)
    {

        return new JPAQuery<Stop>(*entityManager()*).from(c)
                .where(c.key.eq(key))
                .fetchFirst();
    }


@ApplicationScoped
public class EntityManagerProducerImpl implements EntityManagerProducer
{

    @PersistenceContext(unitName = "my-unit")
    private EntityManager entityManager;

    @Produces
   * @RequestScoped*
    public EntityManager get()
    {
        return entityManager;
    }
    public void dispose(@Disposes @Default EntityManager entityManager)
    {
        if (entityManager.isOpen())
        {
            entityManager.close();
        }
    }
}

>From the documentation you propose to use * @RequestScoped*
entityManager...so...what is wrong with this architecture?

I can switch to @TransactionScoped and then annotate the init method with
@Transactional...I suppose it will work...but maybe is not the proper
approach.

Regards,
LA

Reply via email to