Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
11. Jul 2008, 01:02 CET | Link

Hi! I am going to create a seam-gen application that uses Spring to provide the entityManager as described here. But I am worried about compatibility with the EntityHome/EntityQuery classess...

Why?

Well, because they use the @Transactional annotation... is that compatible with spring:spring-transaction? I have the feeling that it will crash with a no transaction is in progress

Am I right?

Regards,

 
Please don't forget to rate

I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death.

3 Replies:
11. Jul 2008, 18:32 CET | Link

Hi!

Well, yes, it crashes (precisely with the error no transaction is in progress), and org.jboss.seam.framework.EntityHome.update has a @Transactional:


@Transactional
   public String update()
   {
      joinTransaction();
      getEntityManager().flush();
      updatedMessage();
      raiseAfterTransactionSuccessEvent();
      return "updated";
   }

Any hints? here is the stacktrace:


10:37:11,562 INFO  [STDOUT] 10:37:11,562 ERROR ExceptionFilter:69 - exception root cause
javax.faces.FacesException: #{monedaHome.update}: /Crud/MonedaEdit.xhtml @58,48 action="#{monedaHome.update}": javax.persistence.TransactionRequiredException: no transaction is in progress
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:107)
	at javax.faces.component.UICommand.broadcast(UICommand.java:383)
	at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:62)
	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 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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	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.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	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.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.faces.el.EvaluationException: /Crud/MonedaEdit.xhtml @58,48 action="#{monedaHome.update}": javax.persistence.TransactionRequiredException: no transaction is in progress
	at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
	... 50 more
Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
	at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:293)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:340)
	at $Proxy157.flush(Unknown Source)
	at org.jboss.seam.persistence.EntityManagerProxy.flush(EntityManagerProxy.java:90)
	at org.jboss.seam.framework.EntityHome.update(EntityHome.java:64)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	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.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
	at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48)
	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
	at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
	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:41)
	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.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 mx.gob.tabasco.sbmi.session.MonedaHome_$$_javassist_6.update(MonedaHome_$$_javassist_6.java)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
	at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:342)
	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.inv
10:37:11,562 INFO  [STDOUT] oke(MethodExpressionImpl.java:276)
	at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
	at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
	... 51 more
 
Please don't forget to rate

I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death.

13. Jul 2008, 18:31 CET | Link

Hi!

So, please correct me if I am wrong:

@Transactional only works for JTA transactions. Why? well, because @Transactional is just there to tell the TransactionInterceptor that the annotated method will be wrapped by an instance of org.jboss.seam.util.Work and its class comment is: Performs work in a JTA transaction.

In other words, @Transactional is doesn't adapt to the current transaction configuration, it does not automatically detect that the PlatformTransactionManager of Spring is configured and therefore it does not use it...

So am I right?

And, if I am right... what can be done? is there a way to override org.jboss.seam.transaction.TransactionInterceptor with my own implementation (one that calls PlatformTransactionManager?)

Regards,

 
Please don't forget to rate

I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death.

14. Jul 2008, 17:34 CET | Link

Hi!

Francisco Peredo wrote on Jul 13, 2008 18:31:
Hi! So, please correct me if I am wrong:

I am wrong!

@Transactional only works for JTA transactions. Why? well, because @Transactional is just there to tell the TransactionInterceptor that the annotated method will be wrapped by an instance of org.jboss.seam.util.Work and its class comment is: Performs work in a JTA transaction.

I am thinking now that org.jboss.seam.util.Work is not used when Spring is used... or something like that... I still don't quite understand how this happens, but @Transactional does work.. and without JTA...

In other words, @Transactional is doesn't adapt to the current transaction configuration, it does not automatically detect that the PlatformTransactionManager of Spring is configured and therefore it does not use it... So am I right?

No, I am wrong, it does adapt, but I still do not understand how.

And, if I am right... what can be done? is there a way to override org.jboss.seam.transaction.TransactionInterceptor with my own implementation (one that calls PlatformTransactionManager?) Regards,

I just had to add this to my applicationContext.xml and now everything works (but I am still confused):


   <bean id="entityManagerFactory" class="org.jboss.seam.ioc.spring.SeamManagedEntityManagerFactoryBean">
 		<property name="persistenceContextName" value="entityManager"/>
	</bean>

It seems that if I do not Re-gift the entity manager to Spring I am not to be able to use @Transaction

It would be nice if someone in this forum could help me understand how the different transaction strategies in seam work...

Regards,

 
Please don't forget to rate

I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death.