1 Reply Latest reply on Apr 6, 2008 7:44 PM by Pete Muir

    need help with entityManager.persist

    Victor Villarreal Newbie

      Click HELP for text formatting instructions. Then edit this text and check the preview.im getting crazy looking how to solve this message:



      Exception during request processing:
      Caused by javax.servlet.ServletException with message: "#{Registro.registro}: org.hibernate.validator.InvalidStateException: validation failed for: org.domain.SerpientesEscaleras.entity.Jugador"



      javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      java.lang.Thread.run(Thread.java:613)



      this is my code:


      Registro.java:


      @Name("Registro")
      public class Registro {
           
          @Logger private Log log;
           
          @In FacesMessages facesMessages;
          
          @In EntityManager entityManager;
          
          private boolean registrado;
          
          public void registro()
          {   
              try
              {
                  Jugador jugador = new Jugador("#{jugadorHome.instance.jugadorNombre}", 
                                                       "#{jugadorHome.instance.jugadorApellidoPaterno}", 
                                                       "#{jugadorHome.instance.jugadorApellidoMaterno}}", 
                                                       "#{jugadorHome.instance.jugadorEmail}", 
                                                       "#{jugadorHome.instance.jugadorUsername}", 
                                                       "#{jugadorHome.instance.jugadorPassword}",
                                                       "novato", new java.sql.Date(System.currentTimeMillis()), 0, 0);
                        entityManager.persist(jugador);
                      facesMessages.add("El usuario #{jugadorHome.instance.jugadorUsername} fue agregado con exito!");
                      registrado = true;
              }
              catch (NoResultException ex)
              {
                 facesMessages.add("No se pudo registrar al usuario, verifique la informacion.");
                 registrado=false;
              }
          }
          
          @Remove
          @Destroy
          public void destroy() {}
      }


      Registro.xhtml



      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                                   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:s="http://jboss.com/products/seam/taglib"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:rich="http://richfaces.org/rich"
                      xmlns:a="http://richfaces.org/a4j"
                      template="layout/template.xhtml">
                             
      <ui:define name="body">
      
          <h:messages globalOnly="true" styleClass="message"/>
      
          <rich:panel>
                 <f:facet name="header">Area de Registro</f:facet>
              <h:form id="RegistroForm">
                   <s:validateAll>
                  <p>Por favor escribe tu informacion para registrarte al jugador</p>
             
                  <div class="dialog">
       
                           <s:decorate id="jugadorNombreDecoration" template="layout/edit.xhtml">
                                <ui:define name="label">Nombre</ui:define>
                                <h:inputText id="jugadorNombre" 
                                       required="true"
                                           size="50"
                                      maxlength="50"
                                          value="#{jugadorHome.instance.jugadorNombre}">
                                    <a:support event="onblur" reRender="jugadorNombreDecoration" bypassUpdates="true" ajaxSingle="true"/>
                                </h:inputText>
                            </s:decorate>
                
                            <s:decorate id="jugadorApellidoPaternoDecoration" template="layout/edit.xhtml">
                                <ui:define name="label">Apellido Paterno</ui:define>
                                <h:inputText id="jugadorApellidoPaterno" 
                                       required="true"
                                           size="50"
                                      maxlength="50"
                                          value="#{jugadorHome.instance.jugadorApellidoPaterno}">
                                    <a:support event="onblur" reRender="jugadorApellidoPaternoDecoration" bypassUpdates="true" ajaxSingle="true"/>
                                </h:inputText>
                            </s:decorate>
                          
                          <s:decorate id="jugadorApellidoMaternoDecoration" template="layout/edit.xhtml">
                                <ui:define name="label">Apellido Materno</ui:define>
                                <h:inputText id="jugadorApellidoMaterno" 
                                       required="true"
                                           size="50"
                                      maxlength="50"
                                          value="#{jugadorHome.instance.jugadorApellidoMaterno}">
                                    <a:support event="onblur" reRender="jugadorApellidoMaternoDecoration" bypassUpdates="true" ajaxSingle="true"/>
                                </h:inputText>
                            </s:decorate>
                
                
                            <s:decorate id="jugadorEmailDecoration" template="layout/edit.xhtml">
                                <ui:define name="label">E-mail</ui:define>
                                <h:inputText id="jugadorEmail" 
                                       required="true"
                                           size="50"
                                      maxlength="100"
                                          value="#{jugadorHome.instance.jugadorEmail}">
                                    <a:support event="onblur" reRender="jugadorEmailDecoration" bypassUpdates="true" ajaxSingle="true"/>
                                </h:inputText>
                            </s:decorate>
                
                
                            <s:decorate id="jugadorUsernameDecoration" template="layout/edit.xhtml">
                                <ui:define name="label">jugadorUsername</ui:define>
                                <h:inputText id="jugadorUsername" 
                                       required="true"
                                           size="20"
                                      minlength="4"
                                      maxlength="20"
                                          value="#{jugadorHome.instance.jugadorUsername}">
                                    <a:support event="onblur" reRender="jugadorUsernameDecoration" bypassUpdates="true" ajaxSingle="true"/>
                                </h:inputText>
                            </s:decorate>
                
                
                            <s:decorate id="jugadorPasswordDecoration" template="layout/edit.xhtml">
                                <ui:define name="label">jugadorPassword</ui:define>
                                <h:inputSecret id="jugadorPassword" 
                                          required="true"
                                          size="20"
                                             minlength="4"
                                                maxlength="20"
                                          value="#{jugadorHome.instance.jugadorPassword}">
                                    <a:support event="onblur" reRender="jugadorPasswordDecoration" bypassUpdates="true" ajaxSingle="true"/>
                                </h:inputSecret>
                            </s:decorate>
                  </div>
                  
                  <div style="clear:both">
                      <span class="required">*</span> 
                      Campos Requeridos
                  </div>
                  
                   <div class="actionButtons">
                       <h:commandButton id="registro" value="Registrar"                view="/Jugador.xhtml"                              action="#{Registro.registro}"/> 
                       <s:button value="Cancelar" action="/login.xhtml"/>                     
                   </div>
                   </s:validateAll> 
              </h:form>    
          </rich:panel>
      </ui:define>
      </ui:composition>