[jboss-user] [JBoss Seam] - No active transaction after validation exception

shakenbrain do-not-reply at jboss.com
Tue Jun 26 10:46:09 EDT 2007


I have a validator class in Seam 1.2.1; I'm using JBoss AS 4.0.2.

@Validator
  | @Name("prefixValidator")
  | public class PrefixValidator extends BaseValidator {
  | 
  |   @In
  |   EntityManager entityManager;
  | 
  |   @Transactional
  |   public void validate(FacesContext context, UIComponent component, Object value)
  |       throws ValidatorException {
  | 
  |     entityManager.joinTransaction();
  | 
  |     String prefix = (String) value;
  |     Query q = entityManager.createQuery("from Organization o where o.prefix = :prefix");
  |     q.setParameter("prefix", prefix.toUpperCase());
  |     if (q.getResultList().size() > 0) {
  |       throw new ValidatorException(makeMessage("Prefix is being used already"));
  |     }
  |   }
  | }

If the validation occurs as the result of an ajax4jsf partial submit (onblur) everything works fine:

  <s:decorate id="prefixDecorator" template="/decorateField.xhtml">
  |     <ui:define name="label">Prefix</ui:define>
  |     <h:inputText id="prefix" size="4" value="#{selectedOrganization.prefix}" required="true"  disabled="#{!organizationAdmin.new}">
  |       <f:validator validatorId="prefixValidator"/>
  |       <a:support event="onblur" reRender="prefixDecorator" oncomplete="this.value=this.value.toUpperCase()"/>
  |     </h:inputText>
  |   </s:decorate>
  | 
However, everything falls apart when I take out the <a:support> tag (causing the validation to occur when the whole form is submitted).  It appears that the transaction ends or is lost.   Any idea why that might be happening? 

  <s:decorate id="prefixDecorator" template="/decorateField.xhtml">
  |     <ui:define name="label">Prefix</ui:define>
  |     <h:inputText id="prefix" size="4" value="#{selectedOrganization.prefix}" required="true"  disabled="#{!organizationAdmin.new}">
  |       <f:validator validatorId="prefixValidator"/>
  |     </h:inputText>
  |   </s:decorate>

The validator fires, throws its validation failed exception (good), and then it appears that the transaction is lost when re-rendering the page.  Here's the log:

07:38:25,396 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: null
  | 07:38:25,396 ERROR [JDBCExceptionReporter] Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=159.sub-75-192-191.myvzw.com/38, BranchQual=, localId=38]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=159.sub-75-192-191.myvzw.com/38, BranchQual=, localId=38])
  | 07:38:25,399 ERROR [ExceptionFilter] uncaught exception
  | javax.servlet.ServletException: /admin/organizationEdit.xhtml @58,90 value="#{timeZoneList}": Cannot get value for expression '#{queryTimeZoneList.resultList}'
  |         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:152)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
  |         at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
  |         at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
  |         at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:53)
  |         at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
  |         at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
  |         at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  |         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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
  |         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
  |         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  |         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  |         at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
  |         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:869)
  |         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
  |         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  |         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
  |         at java.lang.Thread.run(Thread.java:613)
  | 07:38:25,400 ERROR [ExceptionFilter] exception root cause
  | javax.faces.el.EvaluationException: /admin/organizationEdit.xhtml @58,90 value="#{timeZoneList}": Cannot get value for expression '#{queryTimeZoneList.resultList}'
  |         at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:60)
  |         at javax.faces.component.UISelectItems.getValue(UISelectItems.java:55)
  |         at org.jboss.seam.ui.UISelectItems.getValue(UISelectItems.java:166)
  |         at javax.faces.component._SelectItemsIterator.hasNext(_SelectItemsIterator.java:92)
  |         at javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:46)
  |         at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:62)
  |         at javax.faces.component.UIInput.validate(UIInput.java:353)
  |         at javax.faces.component.UIInput.processValidators(UIInput.java:183)
  |         at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
  |         at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
  |         at javax.faces.component.UIForm.processValidators(UIForm.java:70)
  |         at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
  |         at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:146)
  |         at org.ajax4jsf.framework.ajax.AjaxViewRoot.access$201(AjaxViewRoot.java:53)
  |         at org.ajax4jsf.framework.ajax.AjaxViewRoot$3.invokeRoot(AjaxViewRoot.java:302)
  |         at org.ajax4jsf.framework.ajax.JsfOneOneInvoker.invokeOnRegionOrRoot(JsfOneOneInvoker.java:54)
  |         at org.ajax4jsf.framework.ajax.AjaxContext.invokeOnRegionOrRoot(AjaxContext.java:176)
  |         at org.ajax4jsf.framework.ajax.AjaxViewRoot.processValidators(AjaxViewRoot.java:315)
  |         at org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(LifecycleImpl.java:262)
  |         at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
  |         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.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
  |         at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
  |         at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
  |         at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:53)
  |         at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
  |         at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
  |         at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
  |         at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  |         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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
  |         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
  |         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  |         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  |         at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
  |         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:869)
  |         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
  |         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  |         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
  |         at java.lang.Thread.run(Thread.java:613)
  | Caused by: javax.faces.el.EvaluationException: Exception getting value of property resultList of base of type : org.jboss.seam.framework.EntityQuery_$$_javassist_39
  |         at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:96)
  |         at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:532)
  |         at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
  |         at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:383)
  |         at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:69)
  |         at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1684)
  |         at org.jboss.seam.Component.getInstance(Component.java:1633)
  |         at org.jboss.seam.Component.getInstance(Component.java:1610)
  |         at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:53)
  |         at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
  |         at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:134)
  |         at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:65)
  |         at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
  |         at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
  |         at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
  |         ... 62 more
  | Caused by: javax.faces.el.EvaluationException: Bean: org.jboss.seam.framework.EntityQuery_$$_javassist_39, property: resultList
  |         at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:442)
  |         at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:82)
  |         ... 76 more
  | Caused by: java.lang.reflect.InvocationTargetException
  |         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |         at java.lang.reflect.Method.invoke(Method.java:585)
  |         at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:438)
  |         ... 77 more
  | Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection
  |         at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:647)
  |         at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
  |         at org.jboss.seam.framework.EntityQuery.getResultList(EntityQuery.java:42)
  |         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |         at java.lang.reflect.Method.invoke(Method.java:585)
  |         at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
  |         at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
  |         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
  |         at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
  |         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
  |         at org.jboss.seam.interceptors.TransactionInterceptor$1.work(TransactionInterceptor.java:32)
  |         at org.jboss.seam.util.Work.workInTransaction(Work.java:37)
  |         at org.jboss.seam.interceptors.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:27)
  |         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
  |         at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
  |         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
  |         at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
  |         at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
  |         at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
  |         at org.jboss.seam.framework.EntityQuery_$$_javassist_39.getResultList(EntityQuery_$$_javassist_39.java)
  |         ... 82 more



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057741#4057741

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057741



More information about the jboss-user mailing list