there's a session scoped bean 'Identity' which I injected in a @Stateless bean which implements Runnable:
@Stateless
@LocalBean
public class Test implements Runnable {
@Inject
Identity identity;
@Inject
Logger log;
@Override
public void run() {
log.warn("Test: " + this + " " + identity.getAccount().getId());
}
}
There's also a bean which invokes the above Runnable asynchronously:
@Stateless
@LocalBean
public class BeanContextExecutor implements Executor {
@Asynchronous
@Override
public void execute(Runnable command) {
command.run();
}
}
and finally, the invocation looks like this:
@Stateless
public class OtherBean {
@Inject
BeanContextExecutor executor;
...
executor.execute(command);
...
}
When running this I'm getting the following error:
...
Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.SessionScoped
...
Is there any way to propagate the SessionContext to the background thread?
I also tried to submit this Runnable to ManagedExecutorService and even to create a proxy for it with a ContextService and submit a proxy but still getting the same error.
Thanks for any help with this!