in our project, by click a primeFaces command button, a method in a jsf viewScoped bean is called. in this method, a method in a ejb stateless bean is called which in a loop(for loop) execute a query in database. during of run this method in ejb bean, another thread calls the method in the viewScoped bean without any new request and this 2 threads run concurrently. and at end, no results return to client.
commandButton in xhtml form:
<p:commandButton id="btnTestExecute"
value="run"
actionListener="#{drawingEditBean.testExecute()}"
process="@all"
update=":mainForm"
ajax="true"
icon="fa fa-trophy"
oncomplete="blinkNextButton()"/>
jsf bean:
public abstract class DrawingBean implements BaseBean {
private List<DrawingWinnerDto> testResult;
@EJB
private DrawingService drawingService;
@PostConstruct
@Override
public void init() {....}
public void testExecute() throws Exception {
LOG.debug("testExecute started");
testResult = drawingService.execute(drawingHeaderDto.getId());
LOG.debug("testExecute finished");
}
}
@Named
@ViewScoped
public class DrawingEditBean extends DrawingBean {
public static String PAGE_TITLE = "DrawingEdit";
public String getPageTitle() {
return PAGE_TITLE;
}
}
ejb bean:
@Stateless
public class DrawingService {
public List<DrawingWinnerDto> execute(Long drawingId) throws Exception {
Drawing drawingEntity = entityManager.find(Drawing.class, drawingId);
List<DrawingWinnerDto> retValue = new ArrayList<>();
Query queryAlgorithm2Core = entityManager.createNamedQuery("DrawingService.Drawing_Algorithm2_Core");
queryAlgorithm2Core.setParameter("drawing_id", drawingEntity.getId());
queryAlgorithm2Core.setParameter("winner_list", new LargeList("Number_List", winnerCandidates));
for (Reward reward : drawingEntity.getRewards()) {
for (int i = 0; i < reward.getQuantity(); i++) {
Object[] result = (Object[]) queryAlgorithm2Core.getSingleResult();
.....
}
}
return retValue;
}
}
by clicking the command button, testExecute() method is called. and inside it, execute() method is called. during run this method(execute() method), another thread calls the testExecute() method. at end of no thread runs, results show in browser. please help me!