[ https://issues.jboss.org/browse/SEAMFACES-249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12710417#comment-12710417 ]
Bryn Cooke edited comment on SEAMFACES-249 at 8/8/12 4:33 AM: -------------------------------------------------------------- In transaction phase listener a transaction is started at the render response phase. {code:title=TransactionPhaseListener.java} public void handleTransactionsBeforePhase(final PhaseEvent event) { PhaseId phaseId = event.getPhaseId(); if (seamManagedTransactionStatus(phaseId)) { if (phaseId == RENDER_RESPONSE) { persistenceContexts.beforeRender(); begin(phaseId); } } } {code} But then it is only closed if in the invoke application phase, faces context render response is true or faces context response complete is true. {code:title=TransactionPhaseListener.java} public void handleTransactionsAfterPhase(final PhaseEvent event) { PhaseId phaseId = event.getPhaseId(); if (seamManagedTransactionStatus(phaseId)) { boolean commitTran = (phaseId == PhaseId.INVOKE_APPLICATION) || event.getFacesContext().getRenderResponse() || event.getFacesContext().getResponseComplete(); if (commitTran) { commitOrRollback(phaseId); // we commit before destroying contexts, // cos the contexts have the PC in them } } } {code} Usually render response is set to true for get requests, but using Mojarra this is not the case for views with parameters so the transaction is not committed: {code:title=RestoreViewPhase.java:224} ViewMetadata metadata = vdl.getViewMetadata(facesContext, viewId); if (metadata != null) { // perhaps it's not supported // and use it to create the ViewRoot. This will have, at most // the UIViewRoot and its metadata facet. viewRoot = metadata.createMetadataView(facesContext); // Only skip to render response if there are no view parameters Collection<UIViewParameter> params = ViewMetadata.getViewParameters(viewRoot); if (params.isEmpty()) { facesContext.renderResponse(); } } {code} was (Author: bryncooke): In transaction phase listener a transaction is started at the render response phase. TransactionPhaseListener.java public void handleTransactionsBeforePhase(final PhaseEvent event) { PhaseId phaseId = event.getPhaseId(); if (seamManagedTransactionStatus(phaseId)) { if (phaseId == RENDER_RESPONSE) { persistenceContexts.beforeRender(); begin(phaseId); } } } But then it is only closed if in the invoke application phase, faces context render response is true or faces context response complete is true. public void handleTransactionsAfterPhase(final PhaseEvent event) { PhaseId phaseId = event.getPhaseId(); if (seamManagedTransactionStatus(phaseId)) { boolean commitTran = (phaseId == PhaseId.INVOKE_APPLICATION) || event.getFacesContext().getRenderResponse() || event.getFacesContext().getResponseComplete(); if (commitTran) { commitOrRollback(phaseId); // we commit before destroying contexts, // cos the contexts have the PC in them } } } Usually render response is set to true for get requests, but using Mojarra this is not the case for views with parameters so the transaction is not committed: RestoreViewPhase.java:224 ViewMetadata metadata = vdl.getViewMetadata(facesContext, viewId); if (metadata != null) { // perhaps it's not supported // and use it to create the ViewRoot. This will have, at most // the UIViewRoot and its metadata facet. viewRoot = metadata.createMetadataView(facesContext); // Only skip to render response if there are no view parameters Collection<UIViewParameter> params = ViewMetadata.getViewParameters(viewRoot); if (params.isEmpty()) { facesContext.renderResponse(); } } > Transaction not closed when using view parameters > ------------------------------------------------- > > Key: SEAMFACES-249 > URL: https://issues.jboss.org/browse/SEAMFACES-249 > Project: Seam Faces > Issue Type: Bug > Environment: Linux, Tomcat7, Mojarra 2.1.11, Seam Faces 3.1.0 > Reporter: Bryn Cooke > > When using the view parameters the transaction created by the > TransactionPhaseListener in the render response phase is not closed. This > results in the transaction being marked as close on commit and in our web > site we run out of connections to the database. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira _______________________________________________ seam-issues mailing list seam-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/seam-issues