Thanks Harald, That's it. It works like charm now.
On Fri, May 2, 2014 at 7:46 AM, Harald Wellmann <[email protected]>wrote: > Did you try defining your bean as a global alternative? See last section of > http://deltaspike.apache.org/jpa.html. > > Regards, > Harald > > > 2014-05-01 11:15 GMT+02:00 Michael Li <[email protected]>: > > > I did debug through the invocation flow. It invoked > > ResourceLocalTransactionStrategy's "getTransaction" method, not the > > overridden in BeanManagedUserTransactionStrategy. I haven't figured out > why > > "Alternatives" in beans.xml didn't take effect. The current code > structure > > is an ear based gradle multi-project. I'll try it in a simple project > > tomorrow. Thanks for the reply. > > > > Michael. > > > > > > On Thu, May 1, 2014 at 12:34 AM, Mark Struberg <[email protected]> > wrote: > > > > > Hi Michael! > > > > > > BeanManagedUserTransactionStrategy extends > > > ResourceLocalTransactionStrategy. > > > > > > I suggest you create a breakpoint and debug through what this.class() > you > > > get. > > > > > > LieGrue, > > > strub > > > > > > > > > On Thursday, 1 May 2014, 0:53, Michael Li <[email protected]> > wrote: > > > > > > I have configured my beans.xml to use > BeanManagedUserTransactionStrategy > > > >(beans.xml content shown below). However, the > > > >"ResourceLocalTransactionStrategy" is still used from error message. > Any > > > >clue? By the way, I am using JBoss 7.2 and Jta data source. > > > > > > > >*** beans.xml *** > > > > > > > ><?xml version="1.0" encoding="UTF-8"?> > > > ><beans xmlns="http://java.sun.com/xml/ns/javaee" > > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > > > xsi:schemaLocation="http://java.sun.com/xml/ns/javaee > > > >http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> > > > > <interceptors> > > > > > > > > > > > > > ><class>org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor</class> > > > > </interceptors> > > > > <alternatives> > > > > > > > > > ><class>org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStrategy</class> > > > > </alternatives> > > > ></beans> > > > > > > > >*** Exception *** > > > > > > > >Caused by: java.lang.IllegalStateException: A JTA EntityManager cannot > > use > > > >getTransaction() > > > >at > > > > > > > > > >org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:1019) > > > >[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final] > > > >at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > > >[rt.jar:1.7.0_51] > > > >at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > > > >[rt.jar:1.7.0_51] > > > >at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) > > > >[rt.jar:1.7.0_51] > > > >at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_51] > > > >at > > > > > > > > > >org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:45) > > > >[weld-core-1.1.10.Final.jar:2012-10-12 10:00] > > > >at > > > > > > > > > >org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105) > > > >[weld-core-1.1.10.Final.jar:2012-10-12 10:00] > > > >at > > > > > > > > > >org.jboss.weld.proxies.EntityManager$-676163098$Proxy$_$$_WeldClientProxy.getTransaction(EntityManager$-676163098$Proxy$_$$_WeldClientProxy.java) > > > >at > > > > > > > > > >org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy.getTransaction(ResourceLocalTransactionStrategy.java:308) > > > >[deltaspike-jpa-module-impl-0.6.jar:0.6] > > > >at > > > > > > > > > >org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy.rollbackAllTransactions(ResourceLocalTransactionStrategy.java:274) > > > >[deltaspike-jpa-module-impl-0.6.jar:0.6] > > > >at > > > > > > > > > >org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy.execute(ResourceLocalTransactionStrategy.java:153) > > > >[deltaspike-jpa-module-impl-0.6.jar:0.6] > > > >at > > > > > > > > > >org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor.executeInTransaction(TransactionalInterceptor.java:57) > > > >[deltaspike-jpa-module-impl-0.6.jar:0.6] > > > > > > > > > > > >-- > > > >Michael Li > > > > > > > > > > > > > > > > > > > > > > > -- > > Michael Li > > > -- Michael Li
