4 Replies Latest reply on Mar 13, 2009 9:34 PM by Dave Ellery

    Strange error trying to save entity

    Pedro Sena Newbie

      Hi Guys,


      I ad this problem before and solved it using @Transactional annotation in my method.


      But now it came back and I don't know what can be wrong.


      Here is my code:



      @Transactional
              private LocalSupplier registerSupplier(LocalSupplier localSupplier, GlobalSupplier globalSupplier) {
              
                      Person person = new Person();
                      person.setGender(Gender.TOURISTIC);
                      person.setName(localSupplier.getTradingName());
      
                      this.personHome.save(person);
                      
                      PersonInfo personInfo = new PersonInfo();
                      personInfo.setPerson(person);
                      personInfo.setNumberOfLogons(0);
                      personInfo.setDateOfLastLogon(GregorianCalendar.getInstance().getTime());
      
                      this.personInfoHome.save(personInfo);
      
                      PersonalData personData = new PersonalData();
                      personData.setPerson(person);
      
                      this.personalDataHome.save(personData);
      
                      ProfessionalData professionalData = new ProfessionalData();
                      professionalData.setPerson(person);
      
                      this.professionalDataHome.save(professionalData);
      
                      localSupplier.setGlobalSupplier(globalSupplier);
                      
                      this.save(localSupplier);
                      
                      return localSupplier;
                      
              }



      An error is throws in this.save(localSupplier) as follows:



      java.util.NoSuchElementException
              at java.util.LinkedList.getLast(LinkedList.java:122)
              at org.jboss.seam.transaction.EjbSynchronizations.registerSynchronization(EjbSynchronizations.java:111)
              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.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:121)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:110)
              at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
              at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateful.SessionSynchronizationInterceptor.invoke(SessionSynchronizationInterceptor.java:142)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.TxPolicy.invokeInNoTx(TxPolicy.java:66)
              at org.jboss.aspects.tx.TxInterceptor$Supports.invoke(TxInterceptor.java:144)
              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.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:86)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:166)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
              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.stateful.StatefulContainer.localInvoke(StatefulContainer.java:261)
              at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:119)
              at $Proxy64.registerSynchronization(Unknown Source)
              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.jboss.seam.util.Reflections.invoke(Reflections.java:22)
              at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
              at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
              at org.javassist.tmp.java.lang.Object_$$_javassist_11.registerSynchronization(Object_$$_javassist_11.java)
              at org.jboss.seam.transaction.UTTransaction.registerSynchronization(UTTransaction.java:92)
              at org.jboss.seam.async.AbstractDispatcher.scheduleTransactionSuccessEvent(AbstractDispatcher.java:90)
              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.jboss.seam.util.Reflections.invoke(Reflections.java:22)
              at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
              at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
              at org.jboss.seam.async.ThreadPoolDispatcher_$$_javassist_12.scheduleTransactionSuccessEvent(ThreadPoolDispatcher_$$_javassist_12.java)
              at org.jboss.seam.core.Events.raiseTransactionSuccessEvent(Events.java:126)
              at org.jboss.seam.framework.Controller.raiseTransactionSuccessEvent(Controller.java:267)
              at org.jboss.seam.framework.Home.raiseAfterTransactionSuccessEvent(Home.java:459)
              at org.jboss.seam.framework.HibernateEntityHome.persist(HibernateEntityHome.java:53)
              at br.com.netsar.infra.persistence.local.LocalSupplierHome.registerSupplier(LocalSupplierHome.java:79)
              at br.com.netsar.infra.persistence.local.LocalSupplierHome.registerSupplier(LocalSupplierHome.java:44)
              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.jboss.seam.util.Reflections.invoke(Reflections.java:22)
              at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:40)
              at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
              at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:34)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
              at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
              at br.com.netsar.infra.persistence.local.LocalSupplierHome_$$_javassist_6.registerSupplier(LocalSupplierHome_$$_javassist_6.java)
              at br.com.netsar.infra.persistence.TestSpecificQueries$2.testComponents(TestSpecificQueries.java:60)
              at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:163)
              at br.com.netsar.infra.persistence.TestSpecificQueries.testRegisterSupplier(TestSpecificQueries.java:62)
      
      



      I have no idea what can be wrong here.


      Any suggestions are welcome.


      Regards,


      Pedro Sena