2 Replies Latest reply on Nov 21, 2007 10:17 AM by Techie Exchange

    Seam does not work when using with DAO (No transaction...)

    Lanh Tran Newbie

      For various reasons, I need to use Seam with a DAO layer. I try the JPA example (comes with Seam 2.0.0.GA) with WAS 6.1.0.11. It works fine.
      When I add the DAO layer (i.e. no EntityManager is used within the Action classes, DB operations are carried out through DAO methods), all operations (add new user, book new hotel, searching) work EXCEPT the CANCEL booking (which call DAO remove() method). The call is OK, but nothing seems to happen, there is no "delete from..." query logged to the log file.

      I try to add a flush() call right after the remove() call, but error occurs. For unknown reason, there is no transaction!!! below is the trace:

      [21/11/07 11:37:08:249 EST] 0000001e application E javax.persistence.TransactionRequiredException: no transaction is in progress
      javax.faces.el.EvaluationException: javax.persistence.TransactionRequiredException: no transaction is in progress
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
      at javax.faces.component.UICommand.broadcast(UICommand.java:383)
      at javax.faces.component.UIData.broadcast(UIData.java:854)
      at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
      at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
      at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:930)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
      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.RedirectFilter.doFilter(RedirectFilter.java:44)
      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.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:761)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:673)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:498)
      at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
      at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
      at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1455)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:113)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:263)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
      at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
      at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
      at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
      at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
      at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)
      Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
      at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:294)
      at hotelbooking.jpa.dao.GenericDAOImpl.flush(GenericDAOImpl.java:62)
      at hotelbooking.jpa.action.BookingListAction.cancel(BookingListAction.java:68)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:615)
      at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
      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:31)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38)
      at org.jboss.seam.util.Work.workInTransaction(Work.java:40)
      at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
      at hotelbooking.jpa.action.BookingListAction_$$_javassist_2.cancel(BookingListAction_$$_javassist_2.java)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:615)
      at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:328)
      at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:341)
      at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
      at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
      at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
      ... 49 more


      Why the call to remove() has no effect?

      Why there is no transaction here? Should transaction be started automatically for each method inside the Action classes?

      Do you have any idea how to fix the problem?

      Thanks

        • 1. Re: Seam does not work when using with DAO (No transaction..
          Lanh Tran Newbie

          When I remove the line:
          @Scope(SESSION)
          from the beginning of the BookingListAction class, the CANCEL booking works (with or without the call to flush()), I can see the log of the "delete from..." statement . This means that the transaction is enabled when the Scope=SESSION is removed.

          Can anyone explain why???

          Thanks

          • 2. Re: Seam does not work when using with DAO (No transaction..
            Techie Exchange Newbie

             

            "vietbird" wrote:
            For various reasons, I need to use Seam with a DAO layer. I try the JPA example (comes with Seam 2.0.0.GA) with WAS 6.1.0.11. It works fine.
            When I add the DAO layer (i.e. no EntityManager is used within the Action classes, DB operations are carried out through DAO methods), all operations (add new user, book new hotel, searching) work EXCEPT the CANCEL booking (which call DAO remove() method). The call is OK, but nothing seems to happen, there is no "delete from..." query logged to the log file.

            I try to add a flush() call right after the remove() call, but error occurs. For unknown reason, there is no transaction!!! below is the trace:

            [21/11/07 11:37:08:249 EST] 0000001e application E javax.persistence.TransactionRequiredException: no transaction is in progress
            javax.faces.el.EvaluationException: javax.persistence.TransactionRequiredException: no transaction is in progress ...

            Why the call to remove() has no effect?

            Why there is no transaction here? Should transaction be started automatically for each method inside the Action classes?

            Do you have any idea how to fix the problem?

            Thanks


            Try to load the entity from DB and then remove/delete.

            SomeEntity entityBean = entityManager.find(SomeEntity.Class, id);
            entityManager.remove(entityBean);
            


            Hope this helps.

            TechieExchange
            http://techieexchange.wordpress.com/