yup :) thanks John On Thu, Feb 8, 2018 at 12:39 PM, John D. Ament <[email protected]> wrote:
> Luis, > > This issue is solved by using the global alternative in > META-INF/apache-deltaspike.properties. > > John > > On Thu, Feb 8, 2018 at 7:11 AM Luís Alves <[email protected]> wrote: > > > So... from the stack: > > > > Caused by: java.lang.IllegalStateException: A JTA EntityManager cannot > use > > getTransaction() > > at > > > > org.hibernate.jpa.spi.AbstractEntityManagerImpl.getTransaction( > AbstractEntityManagerImpl.java:1333) > > at > > > > org.jboss.as.jpa.container.AbstractEntityManager.getTransaction( > AbstractEntityManager.java:518) > > at org.apache.deltaspike.jpa.impl.transaction. > > *ResourceLocalTransactionStrategy* > > .getTransaction(ResourceLocalTransactionStrategy.java:370) > > at > > > > org.apache.deltaspike.jpa.impl.transaction. > ResourceLocalTransactionStrategy.rollbackAllTransactions( > ResourceLocalTransactionStrategy.java:336) > > at > > > > org.apache.deltaspike.jpa.impl.transaction. > ResourceLocalTransactionStrategy.execute(ResourceLocalTransactionStrate > gy.java:154) > > at > > > > org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner. > executeTransactional(TransactionalQueryRunner.java:72) > > at > > > > org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner. > executeQuery(TransactionalQueryRunner.java:54) > > at > > > > org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner$ > Proxy$_$$_WeldClientProxy.executeQuery(Unknown > > Source) > > at > > > > org.apache.deltaspike.data.impl.handler.QueryHandler. > process(QueryHandler.java:147) > > ... 85 more > > > > I'm on a multi module gradle project. As I said before on the > > \WEB-INF\beans.xml I have: > > > > <?xml version="1.0" encoding="UTF-8"?> > > <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi=" > > http://www.w3.org/2001/XMLSchema-instance" > > xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee > > http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" > > version="1.2" bean-discovery-mode="annotated"> > > > > <alternatives> > > <class>org.apache.deltaspike.jpa.impl.transaction. > > *ContainerManagedTransactionStrategy*</class> > > </alternatives> > > > > </beans> > > > > So...DS is not picking up this. So maybe I might need to place it at > > META-INF/apache-deltaspike.properties, as John point out. Or I need to > > place this alternative on the jar(s) of my sevice layer where the TX is > > started. > > I'm going to try some scenarios this afternoon. > > > > > > > > On Wed, Feb 7, 2018 at 5:35 PM, Luís Alves <[email protected]> > wrote: > > > > > Thanks John. I going to test it tomorrow I hope... > > > > > > Currently I have it like: > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > > <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi=" > > > http://www.w3.org/2001/XMLSchema-instance" > > > xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee > > > http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" > > > version="1.2" bean-discovery-mode="annotated"> > > > > > > <alternatives> > > > <class>org.apache.deltaspike.jpa.impl.transaction. > > > ContainerManagedTransactionStrategy</class> > > > </alternatives> > > > > > > </beans> > > > > > > which as you pointed out might not work. > > > I also do my TX demarcation at the service level (business logic). A > > > Service can use multiple repos, jms, ... > > > Repo should only concern about persisting and querying data. > > > > > > Regards, > > > LA > > > > > > On Tue, Feb 6, 2018 at 9:44 PM, John D. Ament <[email protected]> > > > wrote: > > > > > >> Hi, > > >> > > >> Yes, Mark's input is definitely useful. I can say I've been using DS > + > > >> Repositories + JTA Transactional for a few years now, it all continues > > to > > >> work fine. I'm on Wildfly 10.1 as well. > > >> > > >> The only thing you need to remember is to > > >> add globalAlternatives.org.apache.deltaspike.jpa.spi.transaction > > >> .TransactionStrategy=org.apache.deltaspike.jpa.impl.transact > > >> ion.ContainerManagedTransactionStrategy > > >> to your META-INF/apache-deltaspike.properties file. This is covered > at > > >> http://deltaspike.apache.org/documentation/jpa.html#JTASupport for > > >> Weld/Wildfly instances > > >> > > >> Then you'll get the seamless transactions between DS repositories, > other > > >> JPA use cases, and JMS, etc. Presently I deal with the JMS + SMTP + > > JPA > > >> use case today and haven't seen it falter too much. > > >> > > >> I don't add @Transactional to my repositories, the transaction > boundary > > >> tends to be at a higher level (Services). > > >> > > >> John > > >> > > >> On Tue, Feb 6, 2018 at 3:41 PM Luís Alves <[email protected]> > > wrote: > > >> > > >> > I want to use DS repositories, that's why I've asked about > > >> Transactional. > > >> > As I use Wildfly 10, I can use the standard Transactional instead of > > >> the DS > > >> > one. > > >> > @Mark: thanks for your point of view. I wan't to stay as standard as > > >> > possible, but if I have strange behaviors I'll switch for DS > > annotation. > > >> > Tomorrow I have to deal with some JMS configs, but I'll try to do > some > > >> > testing until the end of this week. I was out for a month and my > > >> colleagues > > >> > are injecting the EntityManager into the @Repositories, because they > > had > > >> > some issues with the TX. I suspect that, this is not a good idea, as > > DS > > >> > repositories should own their own EntityManager instance. > > >> > > > >> > Regards > > >> > > > >> > On Tue, Feb 6, 2018 at 8:20 PM, Mark Struberg > > <[email protected] > > >> > > > >> > wrote: > > >> > > > >> > > Hi! > > >> > > > > >> > > Please note that @javax.transaction.Transactional and deltaspike > > >> > > @Transactional work pretty different under the hood. > > >> > > > > >> > > With javax.transaction.Transactional you will get the weird > > >> transaction > > >> > > handling of EJB [1]. > > >> > > It's also not that portable as it seems. There are huge definition > > >> gaps > > >> > in > > >> > > the tx spec as well. E.g. whether you can catch Exceptions, > > >> transaction > > >> > > boundaries etc. > > >> > > > > >> > > Needless to say I'm not a fan of javax.transaction.Transactional > ;) > > >> > > > > >> > > LieGrue, > > >> > > strub > > >> > > > > >> > > > > >> > > [1] https://struberg.wordpress.com/2015/04/21/transaction- > > >> > > and-exception-handling-in-ejbs-and-javaee7-transactional/ > > >> > > > > >> > > > > >> > > > Am 06.02.2018 um 20:38 schrieb Mauro Chi < > > [email protected] > > >> >: > > >> > > > > > >> > > > If you use wildfly10 it came with jeee7 that already came with > > >> > > > annotation@Transactional. > > >> > > > > > >> > > > So if you use wildfy 10 you dont have to use deltaspike. > > >> > > > Mauro > > >> > > > > > >> > > > Il 6 feb 2018 19:31, "Luís Alves" <[email protected]> ha > > >> scritto: > > >> > > > > > >> > > >> Left the office already...It's wildfly 10 dot something. I'll > > give > > >> the > > >> > > >> exact version and strategy used tomorrow. > > >> > > >> > > >> > > >> Regards > > >> > > >> > > >> > > >> Em 06/02/2018 18:11, "John D. Ament" <[email protected]> > > >> > escreveu: > > >> > > >> > > >> > > >>> Yes, in general javax.transaction.Transactional works well. > > >> > Depending > > >> > > >> on > > >> > > >>> your server, you may need to just point to the container > managed > > >> > > >>> transaction approach. What container are you deploying to > > >> (including > > >> > > >>> version)? > > >> > > >>> > > >> > > >>> On Tue, Feb 6, 2018 at 12:37 PM Luís Alves < > > [email protected] > > >> > > > >> > > >> wrote: > > >> > > >>> > > >> > > >>>> Will deltaspike work with javax.transaction.Transactional? > > >> > > >>>> Do I need to specify an interceptor? > > >> > > >>>> Where can I find an example? > > >> > > >>>> > > >> > > >>> > > >> > > >> > > >> > > > > >> > > > > >> > > > >> > > > > > > > > >
