1 Reply Latest reply on Mar 27, 2009 7:03 PM by d sailer

    Hibernate validation, UI stack trace

    d sailer Newbie

      I'm a new to seam and faces and I'm tweaking a seam-gen crud app changing some of the associations to be dropdowns. I have the dropdowns displayed and setting values on entities when an item is selected. The problem now is that when I Save I get


      Caused by org.hibernate.validator.InvalidStateException with message: "validation failed for: com.orbcrawler.domain.AutoModel"
      org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:143)
      org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:167)
      org.hibernate.action.EntityIdentityInsertAction.preInsert(EntityIdentityInsertAction.java:119)
      org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:42)
      org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
      org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
      org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
      org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
      org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:131)
      org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:87)
      org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38)
      org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
      org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
      org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)
      org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:212)
      org.jboss.seam.persistence.EntityManagerProxy.persist(EntityManagerProxy.java:137)
      org.jboss.seam.framework.EntityHome.persist(EntityHome.java:84)
      



      I'm not sure why I'm getting a stacktrace in the UI rather than a seam validation error. And I'm really not sure where to debug this to see what the validation error is. This is likely related to the change I made to use the dropdown to populate an association like so:


                  <s:decorate id="autoMakeField" template="layout/edit.xhtml">
                      <ui:define name="label">Make</ui:define>
                      <h:selectOneMenu value="#{autoModelHome.instance.autoMake}" required="true">
                         <s:selectItems value="#{autoMakes.resultList}"
                              var="v" label="#{v.name}" noSelectionLabel="Please Select..."/>
                         <s:convertEntity />     
                         <a:support event="onchange" reRender="save" bypassUpdates="false" ajaxSingle="true"/> 
                      </h:selectOneMenu>
                  </s:decorate>
      



      so the question I have is one, where can I set a breakpoint to see what validation is failing? And two, why does this result in a stack-trace in the browser?

        • 1. Re: Hibernate validation, UI stack trace
          d sailer Newbie

          ok, I overrode persist in EntityHome and got some logging:


          2009-03-27 13:24:06,218 INFO  [com.orbcrawler.action.admin.AutoModelHome] Invalid Value: id
          2009-03-27 13:24:06,218 DEBUG [javax.enterprise.resource.webcontainer.jsf.application] No navigation rule found for null outcome and viewId /AutoModelEdit.xhtml Explicitly remain on the current view 
          



          So I noticed my annotations on the id were a bit different on this entity. I removed the @NotNull constraint and it works now. Duh.