5 Replies Latest reply on Oct 22, 2007 8:11 AM by Vincent LAUGIER

    RuntimeException using @Pattern

    John DeStefano Apprentice

      Hi,

      I have an Entity Bean that has attributes annotated like this:

      @Pattern(regex = ".+@.+\\.[a-z]+", message = "Enter a valid e-mail address (xxx@yyy.com).")
      @Column(length = 120)
       public String getEmail() {
       return email;
       }
      
      @NotNull
       @Length(min = 1, max = 15, message = "Between 0 and 15")
       @Column(unique = true)
       public String getUserName() {
       return userName;
       }
      


      I attempt tp persist the associated class like this:

      public String saveAddTeamMember() {
       try {
       em.persist(teammember);
       em.flush();
       teammembers.add(teammember);
       EntitySortingUtils.sortTeamMemberList(teammembers);
       } catch (ConstraintViolationException cve) {
       JSFHelpers.addGeneralMsg(facesContext,
       "Error: User name already in use.");
       return null;
       } catch (EvaluationException ive) {
       System.out.println("************************* In Eval exception");
       JSFHelpers.addGeneralMsg(facesContext,
       "Error: Evaluation error.");
       return null;
       } catch (InvalidStateException ise) {
       System.out.println("************************* In Invalid State exception");
       ise.printStackTrace();
       JSFHelpers.addGeneralMsg(facesContext,
       "Error: Project name already in use.");
       return null;
       } catch (Throwable e) {
       System.out.println("************************* In Eval exception");
       JSFHelpers.addGeneralErrorMsgAndTrace(facesContext, e, true);
       return null;
       }
       return "teammemberlist";
       }


      If the unique contraint on the userName is broken the code executes as I would expect and throws a ConstraintViolationException that is caught and the appropriate action taken. If, however, the email attribute doesn't match the supplied pattern an exception is caught in the InvalidStateException catch block. This is OK but a java.lang.RuntimeException is thrown also that causes an error and stack trace to be dispalyed on the web page. The following trace is output to the console.

      21:04:12,129 INFO [STDOUT] ************************* In Invalid State exception
      21:04:12,129 INFO [STDOUT] org.hibernate.validator.InvalidStateException: validation failed for: org.hhcc.projecttrack.be.TeamMember
      21:04:12,132 INFO [STDOUT] at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:103)
      21:04:12,132 INFO [STDOUT] at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:126)
      21:04:12,133 INFO [STDOUT] at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:138)
      21:04:12,133 INFO [STDOUT] at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:44)
      21:04:12,133 INFO [STDOUT] at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
      21:04:12,133 INFO [STDOUT] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
      21:04:12,133 INFO [STDOUT] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
      21:04:12,133 INFO [STDOUT] at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
      21:04:12,133 INFO [STDOUT] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      21:04:12,133 INFO [STDOUT] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:905)
      21:04:12,133 INFO [STDOUT] at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:185)
      21:04:12,134 INFO [STDOUT] at org.jboss.ejb3.entity.InjectedEntityManager.flush(InjectedEntityManager.java:122)
      21:04:12,134 INFO [STDOUT] at org.hhcc.projecttrack.session.ManageTeamMembersAction.saveAddTeamMember(ManageTeamMembersAction.java:110)
      21:04:12,134 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      21:04:12,134 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      21:04:12,134 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      21:04:12,134 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      21:04:12,134 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
      21:04:12,134 INFO [STDOUT] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:124)
      21:04:12,134 INFO [STDOUT] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:62)
      21:04:12,135 INFO [STDOUT] at org.jboss.seam.interceptors.ValidationInterceptor.validateTargetComponent(ValidationInterceptor.java:57)
      21:04:12,135 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor1186.invoke(Unknown Source)
      21:04:12,135 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      21:04:12,135 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      21:04:12,135 INFO [STDOUT] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      21:04:12,135 INFO [STDOUT] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:81)
      21:04:12,135 INFO [STDOUT] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:66)
      21:04:12,135 INFO [STDOUT] at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:32)
      21:04:12,135 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor1185.invoke(Unknown Source)
      21:04:12,136 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      21:04:12,147 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      21:04:12,147 INFO [STDOUT] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      21:04:12,147 INFO [STDOUT] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:81)
      21:04:12,147 INFO [STDOUT] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:66)
      21:04:12,147 INFO [STDOUT] at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:51)
      21:04:12,148 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor1184.invoke(Unknown Source)
      21:04:12,148 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      21:04:12,148 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      21:04:12,148 INFO [STDOUT] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      21:04:12,148 INFO [STDOUT] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:81)
      21:04:12,148 INFO [STDOUT] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:66)
      21:04:12,148 INFO [STDOUT] at org.hhcc.projecttrack.login.interceptor.LoggedInInterceptor.checkLoggedIn(LoggedInInterceptor.java:29)
      21:04:12,148 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      21:04:12,148 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      21:04:12,162 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      21:04:12,162 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      21:04:12,162 INFO [STDOUT] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      21:04:12,163 INFO [STDOUT] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:81)
      21:04:12,163 INFO [STDOUT] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:66)
      21:04:12,163 INFO [STDOUT] at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:19)
      21:04:12,163 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor1183.invoke(Unknown Source)
      21:04:12,163 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      21:04:12,163 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      21:04:12,163 INFO [STDOUT] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      21:04:12,163 INFO [STDOUT] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:81)
      21:04:12,163 INFO [STDOUT] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:66)
      21:04:12,164 INFO [STDOUT] at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(BusinessProcessInterceptor.java:58)
      21:04:12,164 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor1182.invoke(Unknown Source)
      21:04:12,164 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      21:04:12,164 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      21:04:12,164 INFO [STDOUT] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      21:04:12,164 INFO [STDOUT] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:81)
      21:04:12,164 INFO [STDOUT] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:66)
      21:04:12,164 INFO [STDOUT] at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:31)
      21:04:12,164 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor1181.invoke(Unknown Source)
      21:04:12,165 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      21:04:12,165 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      21:04:12,165 INFO [STDOUT] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      21:04:12,165 INFO [STDOUT] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:81)
      21:04:12,165 INFO [STDOUT] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:66)
      21:04:12,165 INFO [STDOUT] at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:41)
      21:04:12,165 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      21:04:12,165 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      21:04:12,165 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      21:04:12,166 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      21:04:12,166 INFO [STDOUT] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:79)
      21:04:12,166 INFO [STDOUT] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:65)
      21:04:12,166 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      21:04:12,166 INFO [STDOUT] at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:44)
      21:04:12,166 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      21:04:12,166 INFO [STDOUT] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:32)
      21:04:12,180 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      21:04:12,180 INFO [STDOUT] at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:133)
      21:04:12,180 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      21:04:12,180 INFO [STDOUT] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
      21:04:12,180 INFO [STDOUT] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
      21:04:12,181 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      21:04:12,181 INFO [STDOUT] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
      21:04:12,181 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      21:04:12,181 INFO [STDOUT] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
      21:04:12,181 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      21:04:12,181 INFO [STDOUT] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
      21:04:12,181 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      21:04:12,181 INFO [STDOUT] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
      21:04:12,181 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      21:04:12,182 INFO [STDOUT] at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:136)
      21:04:12,182 INFO [STDOUT] at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:83)
      21:04:12,182 INFO [STDOUT] at $Proxy522.saveAddTeamMember(Unknown Source)
      21:04:12,182 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      21:04:12,182 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      21:04:12,182 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      21:04:12,182 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      21:04:12,182 INFO [STDOUT] at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
      21:04:12,183 INFO [STDOUT] at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
      21:04:12,183 INFO [STDOUT] at javax.faces.component.UICommand.broadcast(UICommand.java:106)
      21:04:12,183 INFO [STDOUT] at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
      21:04:12,183 INFO [STDOUT] at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
      21:04:12,183 INFO [STDOUT] at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:301)
      21:04:12,183 INFO [STDOUT] at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
      21:04:12,183 INFO [STDOUT] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
      21:04:12,183 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      21:04:12,183 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      21:04:12,184 INFO [STDOUT] at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
      21:04:12,184 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      21:04:12,184 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      21:04:12,184 INFO [STDOUT] at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:36)
      21:04:12,184 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      21:04:12,184 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      21:04:12,194 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      21:04:12,194 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      21:04:12,195 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      21:04:12,196 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      21:04:12,196 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      21:04:12,196 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      21:04:12,196 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      21:04:12,196 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      21:04:12,196 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      21:04:12,197 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      21:04:12,197 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      21:04:12,197 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      21:04:12,197 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      21:04:12,197 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      21:04:12,197 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      21:04:12,197 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      21:04:12,197 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
      21:04:12,211 ERROR [SeamExceptionFilter] uncaught exception handled by Seam: Error calling action method of component with id _id5:_id14
      21:04:12,225 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      javax.faces.FacesException: Error calling action method of component with id _id5:_id14
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
       at javax.faces.component.UICommand.broadcast(UICommand.java:106)
       at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:301)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
       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:36)
       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:81)
       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.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       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:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
       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:595)
      Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{manageteammembers.saveAddTeamMember}
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
       ... 31 more
      Caused by: java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=cpu18320/103, BranchQual=, localId=103] status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.validator.InvalidStateException: validation failed for: org.hhcc.projecttrack.be.TeamMember)
       at org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:185)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:167)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:74)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:136)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:83)
       at $Proxy522.saveAddTeamMember(Unknown Source)
       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.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
       ... 32 more
      Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=cpu18320/103, BranchQual=, localId=103] status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.validator.InvalidStateException: validation failed for: org.hhcc.projecttrack.be.TeamMember)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:354)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:162)
       ... 51 more
      Caused by: org.hibernate.validator.InvalidStateException: validation failed for: org.hhcc.projecttrack.be.TeamMember
       at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:103)
       at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:126)
       at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:138)
       at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:44)
       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:140)
       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:905)
       at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:185)
       at org.jboss.ejb3.entity.ManagedEntityManagerFactory$SessionSynchronization.beforeCompletion(ManagedEntityManagerFactory.java:89)
       at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1473)
       at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1092)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:306)
       ... 52 more
      


      This seems to be isolated to the @Pattern annotation. Is there a way to catch this exception for graceful handling?

      I'm using JBoss 4.0.3SP1 and the most recent Seam build form CVS.

      Tx

        • 1. Re: RuntimeException using @Pattern
          Gavin King Master

          Since you are catching and handling the exception, you need to do something to force the transaction to roll back. ie. call UT.setRollbackOnly().

          Actually, I believe that the next rev of the EJB3 spec will say that any time an exception propagates out of the EM, the persistence provider must call setRollbackOnly(), which will relieve you of the effort here.

          • 2. Re: RuntimeException using @Pattern
            John DeStefano Apprentice

            Hi Gavin,

            Thanks for the response. Are you suggesting something like this:

            @TransactionAttribute(TransactionAttributeType.NEVER)
            public String saveAddTeamMember() {
             UserTransaction ut = null;
             try {
             ut = InitialContext ic = new InitialContext();
             ic.lookup("UserTransaction");
             ut.begin();
             em.persist(teammember);
             em.flush();
             teammembers.add(teammember);
             EntitySortingUtils.sortTeamMemberList(teammembers);
             ut.commit();
             } catch (Throwable e) {
             System.out.println("************************* In Eval exception");
             JSFHelpers.addGeneralErrorMsgAndTrace(facesContext, e, true);
             if (ut != null)
             try {
             ut.setRollBackOnly();
             } catch (Throwable tr) {
             }
             return null;
             }
             return "teammemberlist";
             }


            Got this to work (I think), however it seems like there might be a better way to do this?

            Tx

            • 3. Re: RuntimeException using @Pattern
              Gavin King Master

              no no no, you don't need to use BMT, instead just inject the EJB SessionContext object using @Resource and call setRollbackOnly() on that. There should be examples of this in the EJB spec.

              • 4. Re: RuntimeException using @Pattern
                Vincent LAUGIER Newbie

                Hello,

                my experience

                I have also meet the invalidStateException with a non required email field

                The field is an email field with a @Email annotation in the entityBean and a s:validateAll in the form

                If I submit the form with an invalid email pattern I receive a nice jsf error message as expected

                if I submit the form without completing the email field, I receive the debug page and the invalidStateException.

                Caused by: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
                 at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1394)
                 at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
                 at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
                 at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
                 ... 84 more
                Caused by: javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: fr.helmet.portal.entity.Account
                 at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:527)
                 at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
                 at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
                 at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
                 at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
                 at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1382)
                 ... 87 more
                Caused by: org.hibernate.validator.InvalidStateException: validation failed for: fr.helmet.portal.entity.Account
                 at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:143)
                 at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:167)
                 at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:156)
                 at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:49)
                 at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
                 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
                 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
                 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
                 at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
                 at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
                 at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
                 at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
                 ... 92 more
                11:17:58,324 ERROR [ExceptionFilter] exception root cause
                javax.faces.FacesException: #{accountManager.registerClient}: java.lang.RuntimeException: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
                 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:107)
                 at javax.faces.component.UICommand.broadcast(UICommand.java:383)
                 at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:186)
                 at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:164)
                 at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:352)
                 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChai
                



                What I have done is tansform the attribute in a null attribute if it has been set to an empty string in the form. This is done before persisting :
                if (this.getAccount().getEmail().equalsIgnoreCase("")) this.getAccount().setEmail(null);
                


                I still do not quite undertsand what is going on but at least it works

                Cheers

                • 5. Re: RuntimeException using @Pattern
                  Vincent LAUGIER Newbie

                  just to be able to watch the forum