0 Replies Latest reply on Sep 18, 2008 6:23 AM by swathi samala

    Could not commit transaction

    swathi samala Newbie
      Hi All,
      I  have created an XHTML file which takes the input text and should save it to the database, but am getting validation exception , can any body please helpme.

      Exception:
      -----------------javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: com.manam.loan.entity.NewUser
           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:1389)
           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.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
           at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:341)
           at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:241)
           at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:192)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
           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(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Unknown Source)
      Caused by: org.hibernate.validator.InvalidStateException: validation failed for: com.manam.loan.entity.NewUser
           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)
           ... 53 more
      09:40:15,031 ERROR [SeamPhaseListener] uncaught exception
      java.lang.IllegalStateException: Could not commit transaction
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:613)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:341)
           at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:241)
           at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:192)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
           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(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Unknown Source)
      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:1401)
           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.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
           at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)
           ... 43 more
      Caused by: javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: com.manam.loan.entity.NewUser
           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:1389)
           ... 48 more
      Caused by: org.hibernate.validator.InvalidStateException: validation failed for: com.manam.loan.entity.NewUser
           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)
           ... 53 more
      09:40:15,453 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/jboss-seam-ui.jar!/META-INF/s.taglib.xml
      09:40:15,453 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/richfaces-ui.jar!/META-INF/a4j.taglib.xml
      09:40:15,484 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/richfaces-ui.jar!/META-INF/ajax4jsf.taglib.xml
      09:40:15,500 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/richfaces-ui.jar!/META-INF/rich.taglib.xml
      09:40:15,516 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/richfaces-ui.jar!/META-INF/richfaces.taglib.xml
      09:40:15,578 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/jboss-seam-mail.jar!/META-INF/seam-mail.taglib.xml
      09:40:15,594 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-core.taglib.xml
      09:40:15,594 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-html.taglib.xml
      09:40:15,609 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-ui.taglib.xml
      09:40:15,609 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-core.taglib.xml
      09:40:15,625 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-fn.taglib.xml
      09:40:15,625 ERROR [STDERR] Sep 18, 2008 9:40:15 AM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/E:/Sakana/jboss-4.2.2.GA/server/default/deploy/loan.war/WEB-INF/lib/jboss-seam-pdf.jar!/META-INF/seam-pdf.taglib.xml


      Action class:
      -------------
      package com.manam.loan.session;

      import java.io.Serializable;
      import java.util.List;

      import javax.ejb.Stateful;
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;

      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.faces.FacesMessages;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.security.Identity;

      import com.manam.loan.entity.NewUser;



      @Name("createUser")
      public class SaveAction implements Serializable {
           @In
           private NewUser newUser;
           
           @In (create=true)
           private EntityManager entityManager;
                
           public String save()
           {     
                entityManager.persist(newUser);
                newUser= new NewUser();
                return null;
          }
      }
           
      Bean class:
      --------------
      package com.manam.loan.entity;

      import java.io.Serializable;

      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.Id;
      import javax.persistence.Table;

      import org.hibernate.validator.Length;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.faces.Validator;

      import com.sun.istack.internal.NotNull;

      @Entity(name="newUser")
      @Name("newUser")
      //@Scope(SESSION)
      @Table(name="newUser")
      public class NewUser implements Serializable {
           private static final long serialVersionUID = 1881413500711441951L;
           private String userName;
           private String password;
           private String confirmPassword;
           private String fullName;
           private String mobileNumber;
           private String emailId;
           @Id@NotNull @Length(min=5, max=15)
           @Column(name="UserName")
           public String getUserName() {          
                return userName;
           }
           public void setUserName(String userName) {
                this.userName = userName;
           }
           
           @Column(name="Password")
           @NotNull @Length(min=5, max=15)
           public String getPassword() {
                return password;
           }
           public void setPassword(String password) {
                this.password = password;
           }
           @Column(name="ConfirmPassword")
           @NotNull @Length(min=5, max=15)
           public String getConfirmPassword() {
                return confirmPassword;
           }
           public void setConfirmPassword(String confirmPassword) {
                this.confirmPassword = confirmPassword;
           }
           
           @Column(name="FullName")
           @NotNull
           public String getFullName() {
                return fullName;
           }
           public void setFullName(String fullName) {
                this.fullName = fullName;
           }
           @Column(name="MobileNumber")
           @NotNull
           public String getMobileNumber() {
                return mobileNumber;
           }
           public void setMobileNumber(String mobileNumber) {
                this.mobileNumber = mobileNumber;
           }
           @Column(name="EmailId")
           @NotNull
           public String getEmailId() {
                return emailId;
           }
           public void setEmailId(String emailId) {
                this.emailId = emailId;
           }

      }