6 Replies Latest reply on Jan 23, 2009 5:54 PM by Julien Kronegg

    what makes' no transaction is in progress'

    leon qian Newbie

      i want to update a database record during a stateful bean destorying.
      i have got these messages belows, who can giveme a hand?


      2008-06-24 14:03:05,937 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
      
      2008-06-24 14:03:05,937 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
      
      2008-06-24 14:03:05,937 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
      
      2008-06-24 14:03:05,937 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postRemoveVariable.visitCountEditor
      
      2008-06-24 14:03:05,937 DEBUG [org.jboss.seam.interceptors.RemoveInterceptor] Stateful component was removed: visitCountEditor
      
      2008-06-24 14:03:05,937 WARN  [org.jboss.seam.contexts.Contexts] Could not destroy component: visitCountEditor
      
      javax.ejb.EJBException: javax.persistence.TransactionRequiredException: no transaction is in progress
      
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
      
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
      
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
      
       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:81)
      
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
       at org.jboss.ejb3.stateful.StatefulRemoveInterceptor.invoke(StatefulRemoveInterceptor.java:81)
      
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
      
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
      
       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:188)
      
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
      
       at $Proxy358.destroy(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:20)
      
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
      
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
      
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
      
       at org.jboss.seam.interceptors.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:40)
      
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
      
       at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
      
       at org.javassist.tmp.java.lang.Object_$$_javassist_26.destroy(Object_$$_javassist_26.java)
      
       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:20)
      
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:123)
      
       at org.jboss.seam.Component.callComponentMethod(Component.java:1834)
      
       at org.jboss.seam.Component.callDestroyMethod(Component.java:1765)
      
       at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:231)
      
       at org.jboss.seam.contexts.Lifecycle.destroyConversationContext(Lifecycle.java:535)
      
       at org.jboss.seam.contexts.Lifecycle.endSession(Lifecycle.java:288)
      
       at org.jboss.seam.servlet.SeamListener.sessionDestroyed(SeamListener.java:45)
      
       at org.apache.catalina.session.StandardSession.expire(StandardSession.java:687)
      
       at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:579)
      
       at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:678)
      
       at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:663)
      
       at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1284)
      
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1569)
      
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1578)
      
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1578)
      
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1558)
      
       at java.lang.Thread.run(Thread.java:595)
      
      Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
      
       at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:264)
      
       at org.jboss.seam.persistence.EntityManagerProxy.flush(EntityManagerProxy.java:83)
      
       at com.CMS.visitcount.VisitCountEditorBean.update(Unknown Source)
      
       at com.CMS.visitcount.VisitCountEditorBean.destroy(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.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
      
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
      
       at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:37)
      
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
      
       at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:47)
      
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      
       at org.jboss.seam.interceptors.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:37)
      
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      
       at org.jboss.seam.interceptors.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:63)
      
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
      
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
      
       at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
      
       at sun.reflect.GeneratedMethodAccessor275.invoke(Unknown Source)
      
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
       at java.lang.reflect.Method.invoke(Method.java:585)
      
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
      
       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.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
      
       ... 52 more
      
      2008-06-24 14:03:05,952 DEBUG [org.jboss.seam.contexts.Contexts] destroying: hotNewsRowList


      my code belows:


      
      @Name("visitCountEditor")
      
      @Stateful
      
      public class VisitCountEditorBean implements VisitCountEditor, Serializable {
      
       
      
       @In(create = true)
      
       private EntityManager entityManager;
      
       
      
       @Valid
      
       private VisitCount visitCount = new VisitCount();
      
       
      
       @Logger
      
       private static Log log;
      
       
      
       public VisitCount getInstance() {
      
        return visitCount;
      
       }
      
       
      
       public void setInstance(VisitCount instance) {
      
        this.visitCount = instance;
      
       }
      
       
      
       @Begin(join = true)
      
       public String create() {
      
        createVisitCount();
      
        Object sessionAttribute = null;
      
        FacesContext facesContext = FacesContext.getCurrentInstance();
      
        ExternalContext externalContext = facesContext.getExternalContext();
      
        Map sessionMap = externalContext.getSessionMap();
      
        log.info("visitcounteditor creat()");
      
        if (sessionMap != null)
      
         sessionAttribute = sessionMap.get("name");
      
        if (sessionAttribute == null) {
      
         // visitCountFinder.findVisitCounts()
      
       
      
         HttpServletRequest request = (HttpServletRequest) externalContext
      
           .getRequest();
      
       
      
         visitCount.setVisitCountIP(request.getRemoteAddr());
      
         DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      
         Date date = new Date();
      
         String str = dateFormat.format(date);
      
       
      
         visitCount.setVisitCountStartTime(str);
      
         entityManager.persist(visitCount);
      
         sessionMap.put("name", visitCount);
      
        }
      
       
      
        return null;
      
       
      
       }
      
       
      
       public String createVisitCount() {
      
       
      
        visitCount = new VisitCount();
      
        return null;
      
       
      
       }
      
       
      
       public String update() {
      
       
      
        if (this.visitCount != null) {
      
         DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      
         Date date = new Date();
      
         String str = dateFormat.format(date);
      
         this.visitCount.setVisitCountEndTime(str);
      
       
      
         entityManager.merge(visitCount);
      
         entityManager.flush();
      
       
      
        }
      
        return null;
      
       }
      
       
      
       @Destroy
      
       @Remove
      
       public void destroy() {
      
        update();
      
        System.out
      
          .println("---------------visit history created!---------------");
      
       }