1 Reply Latest reply on Jun 3, 2006 12:40 PM by Yogendra Rampuria

    How to tackle JBossRollbackException

    Yogendra Rampuria Newbie

      Hi everyone I am trying to use JSF+EJB3 for my project at work. I have this problem with commiting values. Below is the calling and processing code and stacktrace of problem.
      I am using JBoss4.0.4GA and Mysql 3.23
      ------ EJB Code

       public class EmployeeBean implements EmployeeEJBLocal,EmployeeEJBRemote {
       private static Category log =
      Logger.getLogger(EmployeeBean.class.toString());
       @PersistenceContext(name="isehisem")
       private EntityManager em;
       /**
       *This is used to add an Employee to DataBase
       *@param emp Employee
       */
       public void addEmployee(EmployeeData emp) {
      
       try {
       Employee employee=new Employee(emp);
      
       //em.persist(emp.getPerson());
       log.debug("Received Call to Add Employee"+emp.getDesignation());
       em.persist(employee);
      
       } catch (Exception e) {
       throw new EJBException(e);
       }
       }
      

      ----- Bean Invoking Code
      public String submit() {
       EmployeeData emp=new EmployeeData();
       DepartmentData dep=new DepartmentData();
       dep.setDescription(this.getDescription());
       //dep.setHod()
       dep.setName(this.getName());
       emp.setDepartment(dep);
       emp.setDesignation(this.getDesignation());
       //emp.setJoinedOn(this.getJoinedOn());
       /****Person Details********/
       PersonData per=new PersonData();
       /****Contact Details********/
       ContactData mail_contact=new ContactData();
       ContactData phone_contact=new ContactData();
       ContactData mobile_contact=new ContactData();
       Collection contact_collection=new ArrayList();
       contact_collection.add(mail_contact);
       contact_collection.add(phone_contact);
       contact_collection.add(mobile_contact);
      
       mail_contact.setContactType(this.getMailtype());
       mail_contact.setValue(this.getMail());
       mail_contact.setDescription(this.getMailcomment());
      
       phone_contact.setContactType(this.getPhonetype());
       phone_contact.setValue(this.getAreacode()+"-"+this.getPhone());
       phone_contact.setDescription(this.getPhonecomment());
      
       mobile_contact.setContactType(this.getMobiletype());
       mobile_contact.setValue(this.getCountrycode()+"-"+this.getMobile());
       mobile_contact.setDescription(this.getMobilecomment());
       /****Address Details********/
       AddressData address=new AddressData();
       Collection collection_address=new ArrayList();
       collection_address.add(address);
      
       address.setAddressLine1(this.getAddln1());
       address.setAddressLine2(this.getAddln2());
       address.setArea(this.getArea());
       address.setCity(this.getCity());
       address.setCountry(this.getCountry());
       address.setPincode(this.getPincode());
       address.setState(this.getState());
      
       /****Person Details********/
      
       per.setDob(this.getDob());
       per.setContacts(contact_collection);
       per.setAddresses(collection_address);
       //per.setFather()
       //per.setMother()
       per.setFirstname(this.getFname());
       per.setMiddlename(this.getMname());
       per.setLastname(this.getLname());
       per.setGender(this.getGender());
       per.setTitle(this.getTitle());
       /***Employee Details***/
       per.setContacts(contact_collection);
       emp.setStatus(this.getStatus());
       emp.setPerson(per);
       emp.setDepartment(dep);
      
       try{
       ServiceLocator.getEmployeeBean().addEmployee(emp);
       }catch(Exception e){
       e.printStackTrace();
      }
      log.debug("Got call for submit ");
      return "success";
      }
      

      ----- Exception Stack Trace
      0:11:47,940 ERROR STDERRexternal link java.lang.RuntimeException:
      org.jboss.tm.JBossRollbackException: Unable to commit,
      tx=TransactionImpl:XidImplFormatId=257, GlobalId=mis2/14, BranchQual=,
      localId=14external link status=STATUS_NO_TRANSACTION; - nested
      throwable: (javax.persistence.PersistenceException:
      org.hibernate.TransientObjectException: com.ise.his.entity.Person)
      10:11:47,950 ERROR STDERRexternal link at
      org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:198)
      10:11:47,950 ERROR STDERRexternal link at
      org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:180)
      10:11:47,950 ERROR STDERRexternal link at
      org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
      10:11:47,950 ERROR STDERRexternal link at
      org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
      10:11:47,951 ERROR STDERRexternal link at
      org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      10:11:47,951 ERROR STDERRexternal link at
      org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      10:11:47,951 ERROR STDERRexternal link at
      org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      10:11:47,951 ERROR STDERRexternal link at
      org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
      10:11:47,951 ERROR STDERRexternal link at
      org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      10:11:47,951 ERROR STDERRexternal link at
      org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
      10:11:47,951 ERROR STDERRexternal link at
      org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      10:11:47,951 ERROR STDERRexternal link at
      org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
      10:11:47,951 ERROR STDERRexternal link at
      org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      10:11:47,951 ERROR STDERRexternal link at
      org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      10:11:47,952 ERROR STDERRexternal link at
      org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      10:11:47,952 ERROR STDERRexternal link at
      org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:225)
      10:11:47,952 ERROR STDERRexternal link at
      org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:55)
      10:11:47,952 ERROR STDERRexternal link at
      org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      10:11:47,952 ERROR STDERRexternal link at
      org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
      10:11:47,952 ERROR STDERRexternal link at $Proxy100.addEmployee(Unknown Source)
      10:11:47,952 ERROR STDERRexternal link at
      com.ise.his.web.pages.doctor.Doctor.submit(Doctor.java:473)
      10:11:47,952 ERROR STDERRexternal link at
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      10:11:47,952 ERROR STDERRexternal link at
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      10:11:47,955 ERROR STDERRexternal link at
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      10:11:47,955 ERROR STDERRexternal link at
      java.lang.reflect.Method.invoke(Method.java:585)
      10:11:47,955 ERROR STDERRexternal link at
      org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
      10:11:47,955 ERROR STDERRexternal link at
      org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
      10:11:47,955 ERROR STDERRexternal link at
      javax.faces.component.UICommand.broadcast(UICommand.java:106)
      10:11:47,955 ERROR STDERRexternal link at
      javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
      10:11:47,955 ERROR STDERRexternal link at
      javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
      10:11:47,955 ERROR STDERRexternal link at
      org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
      10:11:47,956 ERROR STDERRexternal link at
      org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
      10:11:47,956 ERROR STDERRexternal link at
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
      10:11:47,956 ERROR STDERRexternal link at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      10:11:47,956 ERROR STDERRexternal link at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      10:11:47,956 ERROR STDERRexternal link at
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      10:11:47,956 ERROR STDERRexternal link at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      10:11:47,956 ERROR STDERRexternal link at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      10:11:47,956 ERROR STDERRexternal link at
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      10:11:47,956 ERROR STDERRexternal link at
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      10:11:47,957 ERROR STDERRexternal link at
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      10:11:47,957 ERROR STDERRexternal link at
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
      10:11:47,957 ERROR STDERRexternal link at
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      10:11:47,957 ERROR STDERRexternal link at
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      10:11:47,957 ERROR STDERRexternal link at
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      10:11:47,957 ERROR STDERRexternal link at
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      10:11:47,957 ERROR STDERRexternal link at
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      10:11:47,957 ERROR STDERRexternal link at
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      10:11:47,957 ERROR STDERRexternal link at
      org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      10:11:47,958 ERROR STDERRexternal link at
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      10:11:47,958 ERROR STDERRexternal link at
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      10:11:47,958 ERROR STDERRexternal link at java.lang.Thread.run(Thread.java:595)
      10:11:47,959 ERROR STDERRexternal link Caused by:
      org.jboss.tm.JBossRollbackException: Unable to commit,
      tx=TransactionImpl:XidImplFormatId=257, GlobalId=mis2/14, BranchQual=,
      localId=14external link status=STATUS_NO_TRANSACTION; - nested
      throwable: (javax.persistence.PersistenceException:
      org.hibernate.TransientObjectException: com.ise.his.entity.Person)
      10:11:47,959 ERROR STDERRexternal link at
      org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
      10:11:47,959 ERROR STDERRexternal link at
      org.jboss.tm.TxManager.commit(TxManager.java:240)
      10:11:47,959 ERROR STDERRexternal link at
      org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
      10:11:47,959 ERROR STDERRexternal link ... 50 more
      10:11:47,960 ERROR STDERRexternal link Caused by:
      javax.persistence.PersistenceException:
      org.hibernate.TransientObjectException: com.ise.his.entity.Person
      10:11:48,033 ERROR STDERRexternal link at
      org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:567)
      10:11:48,033 ERROR STDERRexternal link at
      org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:484)
      10:11:48,033 ERROR STDERRexternal link at
      org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
      10:11:48,034 ERROR STDERRexternal link at
      org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
      10:11:48,034 ERROR STDERRexternal link at
      org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
      10:11:48,034 ERROR STDERRexternal link ... 52 more
      10:11:48,036 ERROR STDERRexternal link Caused by:
      org.hibernate.TransientObjectException: com.ise.his.entity.Person
      10:11:48,036 ERROR STDERRexternal link at
      org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
      10:11:48,036 ERROR STDERRexternal link at
      org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
      10:11:48,036 ERROR STDERRexternal link at
      org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
      10:11:48,036 ERROR STDERRexternal link at
      org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
      10:11:48,036 ERROR STDERRexternal link at
      org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2900)
      10:11:48,055 ERROR STDERRexternal link at
      org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:474)
      10:11:48,055 ERROR STDERRexternal link at
      org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:197)
      10:11:48,055 ERROR STDERRexternal link at
      org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:120)
      10:11:48,055 ERROR STDERRexternal link at
      org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
      10:11:48,056 ERROR STDERRexternal link at
      org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
      10:11:48,056 ERROR STDERRexternal link at
      org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
      10:11:48,060 ERROR STDERRexternal link at
      org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
      10:11:48,060 ERROR STDERRexternal link at
      org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:340)
      10:11:48,061 ERROR STDERRexternal link at
      org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:475)
      10:11:48,061 ERROR STDERRexternal link ... 55 more
      

      -----------------------------------------

      Thanks in advance.