I have a JSF 2 application (running on top of JBoss AS 7.1) that has to start a long process when the user clicks a button in a page. The idea is to have a not blocking interaction, so the user can wait and see the results or simply close the page and get back later to see how it is going or the results, if the process is concluded already.
The process itself is coded in a following (simplified) class:
@Stateless
@LocalBean
@ApplicationScoped
public class MyProcessManager {
@Inject
private ProcessHelper processHelper;
@Asynchronous
public void start(final ProcessParameters parameters) {
// the process...
}
}
Such a class is marked as @ApplicationScoped
because all the processes running (for all the users) are kept by it. So, when the button is clicked, the backing bean sets some parameters and calls the asynchronous method start()
.
Everything goes ok until the moment the process tries to use processHelper
, which runs a number of Hibernate queries in order to proceed with the persistence part of the process. When the first method of processHelper
is called I get the follwing exception:
WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
As an additional info, a breakpoint inside of such a method is never hit.
What is happening and how to fix it?