Thanks for the quick reply Gavin, and apologies for not providing enough info to start with. I've posted the full code for the seam managed bean, the facelet code and the full stack-trace.
I do use the @TransactionAttribute(NOT_SUPPORTED) - but perhaps just not in the right places? (I added the tx attribs to prevent auto-flushing between wizard steps).
Seam managed bean:
@Stateful
@Name ( "wizard" )
@Scope ( ScopeType.CONVERSATION )
@Interceptors ( SeamInterceptor.class )
public class WizardAction implements Wizard {
private static final Logger LOG = Logger.getLogger( WizardAction.class );
@In(create=true)
private EntityManager em;
@Resource
SessionContext ctx;
@DataModel
private List<WizardTest> testList;
@DataModelSelectionIndex
private int selectionIndex ;
@Valid
@Out(scope = ScopeType.CONVERSATION, required = false)
private WizardTest selection ;
@Factory ( "testList" )
public void buildTestList () {
LOG.info("Entity Manager Class: " + em.getClass().getName());
testList = em.createNamedQuery( "wizardTest.findAll" ).getResultList() ;
}
@Begin
public String editItem() {
selection = testList.get(selectionIndex) ;
return "page1" ;
}
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public String next() {
return "page2" ;
}
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public String prev() {
return "page1" ;
}
@End
public String cancel() {
em.refresh(selection);
return "list" ;
}
@End ( ifOutcome = "saved" )
@IfInvalid( outcome = Outcome.REDISPLAY )
public String save() {
em.persist(selection);
return "saved" ;
}
@Remove
@Destroy
public void destroy() { }
}
TestList.xhtml - lists the entities:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body id="pgMainMenu">
<f:view>
<h:form>
<p>Select An Item to edit...</p>
<t:dataList id="listData"
var="rowData"
value="#{testList}"
rowIndexVar="rowIndex">
<h:commandLink action="#{wizard.editItem}" value="Edit Item #{rowData.id}" />
<br />
</t:dataList>
</h:form>
</f:view>
</body>
</html>
TestPage1.xhtml - Step 1 of wizard:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body id="pgMainMenu">
<f:view>
<h:form>
<table>
<tr>
<td>
<h:outputLabel for="listId">ID:</h:outputLabel>
</td>
<td>
<h:outputText id="listId" value="#{selection.id}" />
</td>
</tr>
<tr>
<td>
<h:outputLabel for="v1">Value1: </h:outputLabel>
</td>
<td>
<h:inputText id="v1" value="#{selection.page1Value}" />
</td>
</tr>
<tr>
<td colspan="2" class="text-align: right;">
<h:commandLink action="#{wizard.cancel}">
Cancel
</h:commandLink>
<h:commandLink action="#{wizard.prev}">
Back
</h:commandLink>
<h:commandLink action="#{wizard.next}">
Next
</h:commandLink>
</td>
</tr>
</table>
</h:form>
</f:view>
</body>
</html>
TestPage2.xhtml - 2nd (final) Step of wizard:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body id="pgMainMenu">
<f:view>
<h:form>
<table>
<tr>
<td>
<h:outputLabel for="listId">ID:</h:outputLabel>
</td>
<td>
<h:outputText id="listId" value="#{selection.id}" />
</td>
</tr>
<tr>
<td>
<h:outputLabel for="v2">Value2: </h:outputLabel>
</td>
<td>
<h:inputText id="v2" value="#{selection.page2Value}" />
</td>
</tr>
<tr>
<td colspan="2">
<h:messages showDetail="true" />
</td>
</tr>
<tr>
<td colspan="2" class="text-align: right;">
<h:commandLink action="#{wizard.cancel}">
Cancel
</h:commandLink>
<h:commandLink action="#{wizard.prev}">
Back
</h:commandLink>
<h:commandLink action="#{wizard.save}">
Save
</h:commandLink>
</td>
</tr>
</table>
</h:form>
</f:view>
</body>
</html>
Full stack trace:
25-04 15:43:47 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalStateException: Could not commit transaction
at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.commit(SeamExtendedManagedPersistencePhaseListener.java:83)
at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.afterPhase(SeamExtendedManagedPersistencePhaseListener.java:49)
at org.apache.myfaces.lifecycle.LifecycleImpl.informPhaseListenersAfter(LifecycleImpl.java:519)
at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:332)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:84)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:44)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1145976022084/22, BranchQual=null:1145976022084, localId=0:22], status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.validator.InvalidStateException: validation failed for: uk.co.iblocks.jobsite.data.WizardTest)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:1283)
at org.jboss.tm.TxManager.commit(TxManager.java:587)
at org.jboss.ejb3.embedded.UserTransactionImpl.commit(UserTransactionImpl.java:90)
at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.commit(SeamExtendedManagedPersistencePhaseListener.java:77)
... 28 more
Caused by: org.hibernate.validator.InvalidStateException: validation failed for: uk.co.iblocks.jobsite.data.WizardTest
at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:104)
at org.hibernate.validator.event.ValidateEventListener.onPreUpdate(ValidateEventListener.java:132)
at org.hibernate.action.EntityUpdateAction.preUpdate(EntityUpdateAction.java:209)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:64)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:3056)
at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:2614)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:1191)
... 31 more