1 2 Previous Next 16 Replies Latest reply on Apr 27, 2007 2:21 PM by pmuir

    Validation fails in registration example

    eekboom

      Seam 1.1.0 GA
      Built registration example with ant, deployed to JBoss AS 4.0.5.

      When I leave the password field empty I get a message "Validation Error" as expected.
      However if I enter one to four characters, I get a nasty exception:

      01:48:04,593 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      javax.faces.FacesException: Error calling action method of component with id _idJsp0:_idJsp5
       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:94)
       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       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.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:619)
      Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{register.register}
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
       at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:59)
       at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:71)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
       ... 25 more
      Caused by: java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=DG7F132J/19, BranchQual=, localId=19
      ] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.ex
      ample.registration.User)
       at org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:198)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:180)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:211)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
       at $Proxy87.register(Unknown Source)
       at org.jboss.seam.example.registration.Register$$FastClassByCGLIB$$46e07125.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:73)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
       at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:38)
       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:597)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
       at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
       at org.jboss.seam.intercept.ClientSideInterceptor.interceptInvocation(ClientSideInterceptor.java:82)
       at org.jboss.seam.intercept.ClientSideInterceptor.intercept(ClientSideInterceptor.java:51)
       at org.jboss.seam.example.registration.Register$$EnhancerByCGLIB$$8aa421a0.register(<generated>)
       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:597)
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
       ... 28 more
      Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=DG7F132J/19, BranchQual=, localId=19] status=STATUS_NO_TRANSACTI
      ON; - nested throwable: (javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.example.registration.User)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
       at org.jboss.tm.TxManager.commit(TxManager.java:240)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
       ... 69 more
      Caused by: javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.example.registration.User
       at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:527)
       at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
       at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
       ... 71 more
      Caused by: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.example.registration.User
       at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:132)
       at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:156)
       at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:139)
       at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:44)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
       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)
       ... 74 more


        • 1. Re: Validation fails in registration example

          I met this problem.Finally I find the length of "username" and "password" are not allowed less than 5.I input string which length is less than 5.Maybe this demo is not perfect,it throws exception for this validation.

          • 2. Re: Validation fails in registration example

            I also got the same problem while deploying the registration example on Tomcat. On some inputs, it passes. On others, it will throw the exception like above.

            • 3. Re: Validation fails in registration example
              gavin.king

              Well, I am not able to reproduce this, so if you really think this problem exists, you guys are going to have to do some research and figure out the cause. It works perfectly for me.

              • 4. Re: Validation fails in registration example
                jtyrrell

                Okay I saw this and filed a bug on this here....http://jira.jboss.com/jira/browse/JBSEAM-627...this has to be a problem and not just me being crazy. Glad to see someone else saw this. I will look at this some more and try to reproduce. I think it has something to do with the downloaded release and maybe building the example for Tomcat although I am not sure. Maybe it is an odd dependency in the timestamps of the shipped/downloaded 1.1.0 GA release.

                • 5. Re: Validation fails in registration example

                  Strange. My colleague showed me the exact problem this afternoon on his computer when he tried to deploy the registration example on his instance of Tomcat. I can only recall now that the validation would fail on his environment.

                  I could not reproduce it on my machine, however.

                  • 6. Re: Validation fails in registration example
                    gavin.king

                    Are you sure its not just because you forgot to do an "ant clean" in between "ant deploy" and "ant deploy.tomcat" and vice-versa?

                    • 7. Re: Validation fails in registration example

                      I just came across something peculiar where I found the registration example in Seam 1.1.0GA does not include jboss-seam-ui.jar. Can someone confirm this? I'm just thinking that I missed a step somewhere.

                      I did an "ant" in seam root, then an "ant tomcat.deploy" in examples/registration. Got a ~16MB file that excludes jboss-seam-ui.jar. Got an exception when opening up the page stating the obvious:

                      java.lang.NoClassDefFoundError: org/jboss/seam/ui/tag/ValidateAllTag
                       at org.apache.jsp.register_jspx._jspx_meth_s_validateAll_0(register_jspx
                      .java:158)
                       at org.apache.jsp.register_jspx._jspx_meth_h_form_0(register_jspx.java:1
                      ..
                      


                      Repeated instructions on a nightly jboss-seam-CVS.20070108. Got a ~18MB file that included jboss-seam-ui.jar (the extra 2MB was made up by the ui jar and itext). Example runs fine.



                      • 8. Re: Validation fails in registration example

                        Okay, I think I reproduced it.

                        The exception that the OP posted occurs on Tomcat 5.5.17 with a Seam 1.1.0GA registration example. For some reason, this version of tomcat will allow me to load up the registration page, but if I enter inputs "abcd" for all three form fields, you will see the exception.

                        On Tomcat 5.5.20 as I stated in the post above, you will not even get that far. Not sure about JBoss. Hope this helps.

                        • 9. Re: Validation fails in registration example
                          dasufe

                          Im having the same issue with the same configuration:
                          Seam 1.1.0 GA
                          Built registration example with ant, deployed to JBoss AS 4.0.5.

                          "When I leave the password field empty I get a message "Validation Error" as expected."

                          This validation error comes from register.jspx. The input text boxes have the attribute required=true. If you remove it wou will have the same exception.

                          It seems that the restrictions on User.java, that is
                          @NotNull @Length(min=5, max=15)
                          are the root cause. As the length of the field is less than 5, an exception is being thrown and no being caught.
                          Hope this helps

                          • 10. Re: Validation fails in registration example
                            tvrtko

                            Same problem here:
                            * jboss-4.0.5.GA-ejb3
                            * jboss-seam-1.1.0.GA
                            * built with ant deploy

                            when I enter less than 5 characters for password I get the exception:

                            ...
                            Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=tvrtko/21, BranchQual=, localId=21] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.example.registration.User)
                             at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
                             at org.jboss.tm.TxManager.commit(TxManager.java:240)
                             at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
                             ... 69 more
                            Caused by: javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.example.registration.User
                            


                            This suggests that JSF validation didn't catch the problem and example code tried to persist invalid record. Hibernate didn't like this...

                            It is interesting that validation catches empty password as error.

                            • 11. Re: Validation fails in registration example
                              tvrtko

                              Same thing happens when I deploy example on tomcat 5.5

                              • 12. Re: Validation fails in registration example

                                What happens if you copy "jboss-seam-ui.jar" from Seam root to WEB-INF/lib of the registration web app?

                                • 13. Re: Validation fails in registration example
                                  tvrtko

                                  Again, I get the error.

                                  Also, I tried changing Test case like this (I only shortened the password to three characters, and commented the following assert):

                                  public class RegisterTest extends SeamTest
                                  {
                                  
                                   @Test
                                   public void testLogin() throws Exception
                                   {
                                  
                                   new FacesRequest("/register.jspx") {
                                  
                                   @Override
                                   protected void processValidations() throws Exception
                                   {
                                   validateValue("#{user.username}", "1ovthafew");
                                   validateValue("#{user.name}", "Gavin King");
                                   validateValue("#{user.password}", "sec");
                                   //assert !isValidationFailure();
                                   }
                                  


                                  If I run ant testexample, it fails with:

                                  FAILED: org.jboss.seam.example.registration.test.RegisterTest.testLogin()
                                  java.lang.NullPointerException
                                   at org.jboss.seam.core.Validation.validate(Validation.java:70)
                                   at org.jboss.seam.mock.SeamTest$Request.validateValue(SeamTest.java:372)
                                   at org.jboss.seam.example.registration.test.RegisterTest$1.processValidations(RegisterTest.java:21)
                                   at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:454)
                                   at org.jboss.seam.example.registration.test.RegisterTest.testLogin(RegisterTest.java:16)
                                   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.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:529)
                                   at org.testng.internal.Invoker.invokeMethod(Invoker.java:398)
                                   at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:625)
                                   at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:88)
                                   at org.testng.TestRunner.privateRun(TestRunner.java:614)
                                   at org.testng.TestRunner.run(TestRunner.java:505)
                                   at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
                                   at org.testng.SuiteRunner.run(SuiteRunner.java:147)
                                   at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
                                   at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
                                   at org.testng.TestNG.run(TestNG.java:316)
                                   at org.testng.TestNG.privateMain(TestNG.java:666)
                                   at org.testng.TestNG.main(TestNG.java:608)
                                  


                                  The offending line is:

                                  ClassValidator validator = getValidator( model.getClass(), componentName );
                                  


                                  so I guess that model is null.

                                  • 14. Re: Validation fails in registration example
                                    tvrtko

                                    Problem solved with seam 1.1.1

                                    1 2 Previous Next