1

I have EJB bean and there is a class RemoveInactiveUsersTask extends TimerTask when I invoke method which update user status in DB.

This is sample code of my class:

@Singleton
@Named
@ApplicationScoped
public class UsersStatusManager implements Serializable {

@SuppressWarnings("CdiInjectionPointsInspection")
    @Inject
    private EntityManager entityManager;

...


}

And this is my errors:

Exception in thread "Timer-2" javax.ejb.EJBException: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.RequestScoped

I use JSF with CDI and Seam 3. Method is of course annotate with @Transactional and everything is ok until I use it in timer. I tried to use unmanaged EntityManager but then I have transaction required exceptions.

Any ideas how I can solve this problem?

Piotr Kozlowski
  • 899
  • 1
  • 13
  • 25
  • So what does the `RemoveInactiveUsersTask` class look like? I suspect you have a request scope on one of your EJB's - if you do and you try to run it in a separate thread - it won't work, as there is no request context available there. – dratewka May 12 '13 at 14:02

1 Answers1

4

The exception is correct, there is no active request context here. You should try a lower scope; e.g. dependent.

John Ament
  • 11,595
  • 1
  • 36
  • 45