You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by nicolasduminil <ni...@simplex-software.fr> on 2016/08/05 16:08:04 UTC

A JTA EntityManager cannot use getTransaction()

Greetings,I'm trying to use DeltaSpike 1.6.1 JPA/Data module with JBoss EAP
6.4.My repository is as follows:@Repositorypublic interface
CustomerRepository extends EntityRepository<CustomerEntity, BigInteger>{}My
entity manager producer is as follows:public class EntityManagerProducer{ 
@PersistenceContext  private EntityManager em;  @Produces 
@TransactionScoped  public EntityManager createEntityManager()  {    return
em;  }Notice that I'm not overriding the closeEntityManager() methos as, in
my context, only the container may close the EntityManager.My service looks
as follows:@Path("/customers")public class CustomerService{  @Inject 
private CustomerRepository customerRepository;    @POST 
@Consumes("application/json")  public Response createCustomer(Customer
customer)  {    CustomerEntity customerEntity = new CustomerEntity
(customer);    customerEntity = customerRepository.save(customerEntity);   
return Response.created(URI.create("/customers/" +
customerEntity.getId())).build();  }}My persistence.xml looks as
follows:<?xml version="1.0" encoding="UTF-8" standalone="yes"?>     
org.hibernate.ejb.HibernatePersistence    java:jboss/datasources/ExampleDS   
false                                        Last but not least, my
beans.xml looks as follows:<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>     
org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStrategy 
Deploying on EAP 6.4.0 raises the following:Caused by:
java.lang.IllegalStateException: A JTA EntityManager cannot use
getTransaction()	at
org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:1019)
[hibernate-entitymanager-4.2.22.Final-redhat-1.jar:4.2.22.Final-redhat-1]	at
org.jboss.as.jpa.container.AbstractEntityManager.getTransaction(AbstractEntityManager.java:498)
[jboss-as-jpa-7.5.6.Final-redhat-2.jar:7.5.6.Final-redhat-2]	at
sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source) [:1.8.0_65]	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.8.0_65]	at java.lang.reflect.Method.invoke(Method.java:497)
[rt.jar:1.8.0_65]	at
org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:45)
[weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]	at
org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
[weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]	at
org.jboss.weld.proxies.EntityManager$2068912035$Proxy$_$$_WeldClientProxy.getTransaction(EntityManager$2068912035$Proxy$_$$_WeldClientProxy.java)
[weld-core-1.1.31.Final-redhat-1.jar:]	at
org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy.getTransaction(ResourceLocalTransactionStrategy.java:370)
[deltaspike-jpa-module-impl-1.6.1.jar:1.6.1]	at
org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy.rollbackAllTransactions(ResourceLocalTransactionStrategy.java:336)
[deltaspike-jpa-module-impl-1.6.1.jar:1.6.1]	at
org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy.execute(ResourceLocalTransactionStrategy.java:154)
[deltaspike-jpa-module-impl-1.6.1.jar:1.6.1]	at
org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner.executeTransactional(TransactionalQueryRunner.java:72)
[deltaspike-data-module-impl-1.6.1.jar:1.6.1]	at
org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner.executeQuery(TransactionalQueryRunner.java:54)
[deltaspike-data-module-impl-1.6.1.jar:1.6.1]	at
org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner$Proxy$_$$_WeldClientProxy.executeQuery(TransactionalQueryRunner$Proxy$_$$_WeldClientProxy.java)
[deltaspike-data-module-impl-1.6.1.jar:1.6.1]	at
org.apache.deltaspike.data.impl.handler.QueryHandler.process(QueryHandler.java:147)
[deltaspike-data-module-impl-1.6.1.jar:1.6.1]	... 38 moreI can't figure out
what the problem might be. The equivalent code, or almost, works properly in
a Java SE environment. Also, not using DeltaSpike JPA/Data but just a
stateless session bean, works properly. But I would prefer to use the
repositories. Please help !Many thanks in advance,Nicolas



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Well it clearly states this is for weld and you use it - not sure what is
unclear but happy to correct the wording if needed.

If it didnt work with this it is either an issue on your side or an unknow
big with your versions. Both cases - in particular first one - need a
sample and not copied/pasted content because you can have used a wrong
location or something like that. So back to the original request.

Le 6 août 2016 13:11, "nicolasduminil" <ni...@simplex-software.fr>
a écrit :

> Yes, I have seen this note and, what this is saying is that, in my case, I
> don't have to configure the transaction strategy in
> apache-deltaspike.properties, since I'm not using OpenWebBeans, neither in
> BDA mode, nore otherwise.
>
> But to make sure, I've added theis to my META-INF folder:
>
> globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.
> TransactionStrategy=org.apache.deltaspike.jpa.impl.transaction.
> ContainerManagedTransactionStrategy
>
> The result is exactly the same:
>
> ...
> at
> org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrate
> gy.getTransaction(ResourceLocalTransactionStrategy.java:370)
> [deltaspike-jpa-module-impl-1.6.1.jar:1.6.1]
> ...
>
>
>
> --
> View this message in context: http://apache-deltaspike-
> incubator-discussions.2316169.n4.nabble.com/A-JTA-
> EntityManager-cannot-use-getTransaction-tp4663224p4663234.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>

Re: A JTA EntityManager cannot use getTransaction()

Posted by Gerhard Petracek <ge...@gmail.com>.
@romain:
+1 & thx
(however, i'm not sure that we should mention some servers explicitly. that
sounds like all other weld based servers are fine...)

@nicolas:
i don't see the issue with the initial version. some of our users proofread
that part already and we can't list all the servers explicitly (which are
affected) at every corner of the documentation.
if you read "some versions of Weld" and a big info-icon which marks the
alternative approach, you should give the alternative approach a try before
sending a harsh response.
i haven't asked you to (re-)read the whole page.
the referenced part consists of less than 10 sentences describing 2 configs.
you are welcome to ask questions about parts of the documentation you don't
understand (for whatever reason).
(and we will try to improve that parts without "overdocumenting" them...)

however, you received the (correct) pointer within 2 hours (on a friday
evening).
people who like to get help with upcoming/further questions from a
community are usually a bit more thankful (at least here at apache).

regards,
gerhard



2016-08-06 18:14 GMT+02:00 Romain Manni-Bucau <rm...@gmail.com>:

> My 2cts will be: info was there and will in the future misunderstood again
> (we didnt mention payara or tomee for instance). Since info is there it is
> fine to enhance it ondemand from now on IMHO (each server community has
> different users asking on different places so overdocumenting can just add
> noise instead of clarification).
>
> It is true we didnt mention ConfigSource but default properties file but it
> avoids one indirection for the BDA workaround so I think it was the thing
> to do: we cant document all features on each usage for each workaround
> without loosing users more than helping them.
>
> That said happy we sorted it out and hope doc is a bit better now.
>
> Le 6 août 2016 17:49, "nicolasduminil" <nicolas.duminil@simplex-
> software.fr>
> a écrit :
>
> > Please understand also that nobody said it was limited to
> > META-INF/apache-deltaspike.properties. You probably missunderstood me.
> I'm
> > not a native English speaker and, sometimes, I could be mistaken in my
> > written expression. However, this time I think I was clear enough:
> > *including but not limited to Weld 1.1.36 and OpenWebBeans.*
> >
> >
> >
> > --
> > View this message in context: http://apache-deltaspike-
> > incubator-discussions.2316169.n4.nabble.com/A-JTA-
> > EntityManager-cannot-use-getTransaction-tp4663224p4663241.html
> > Sent from the Apache DeltaSpike Incubator Discussions mailing list
> archive
> > at Nabble.com.
> >
>

Re: A JTA EntityManager cannot use getTransaction()

Posted by Romain Manni-Bucau <rm...@gmail.com>.
My 2cts will be: info was there and will in the future misunderstood again
(we didnt mention payara or tomee for instance). Since info is there it is
fine to enhance it ondemand from now on IMHO (each server community has
different users asking on different places so overdocumenting can just add
noise instead of clarification).

It is true we didnt mention ConfigSource but default properties file but it
avoids one indirection for the BDA workaround so I think it was the thing
to do: we cant document all features on each usage for each workaround
without loosing users more than helping them.

That said happy we sorted it out and hope doc is a bit better now.

Le 6 août 2016 17:49, "nicolasduminil" <ni...@simplex-software.fr>
a écrit :

> Please understand also that nobody said it was limited to
> META-INF/apache-deltaspike.properties. You probably missunderstood me. I'm
> not a native English speaker and, sometimes, I could be mistaken in my
> written expression. However, this time I think I was clear enough:
> *including but not limited to Weld 1.1.36 and OpenWebBeans.*
>
>
>
> --
> View this message in context: http://apache-deltaspike-
> incubator-discussions.2316169.n4.nabble.com/A-JTA-
> EntityManager-cannot-use-getTransaction-tp4663224p4663241.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>

Re: A JTA EntityManager cannot use getTransaction()

Posted by nicolasduminil <ni...@simplex-software.fr>.
Please understand also that nobody said it was limited to
META-INF/apache-deltaspike.properties. You probably missunderstood me. I'm
not a native English speaker and, sometimes, I could be mistaken in my
written expression. However, this time I think I was clear enough:
*including but not limited to Weld 1.1.36 and OpenWebBeans.*



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663241.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by "John D. Ament" <jo...@apache.org>.
Please also understand its not limited to
META-INF/apache-deltaspike.properties, but any other config source you may
have at runtime.

On Sat, Aug 6, 2016 at 9:53 AM Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Updated the website, let me know if it is not better.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com> | JavaEE Factory
> <https://javaeefactory-rmannibucau.rhcloud.com>
>
> 2016-08-06 13:36 GMT+02:00 nicolasduminil <
> nicolas.duminil@simplex-software.fr>:
>
> > I would propose the following:
> >
> > "In the case of some versions of Weld, including but not limited to Weld
> > 1.1.36 which comes with JBoss EAP/Wildfly, or OpenWebBeans in BDA mode,
> you
> > have to configure it as a global alternative instead of an alternative in
> > beans.xml. That means you have to add either
> >
> > globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.
> > TransactionStrategy
> >
> =org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStra
> > tegy
> >
> > or
> >
> > globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.
> > TransactionStrategy
> >
> =org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStr
> > ategy
> >
> > depending on your BMT/CMT strategy, to the
> > /META-INF/apache-deltaspike.properties file"
> >
> >
> >
> > --
> > View this message in context: http://apache-deltaspike-
> > incubator-discussions.2316169.n4.nabble.com/A-JTA-
> > EntityManager-cannot-use-getTransaction-tp4663224p4663238.html
> > Sent from the Apache DeltaSpike Incubator Discussions mailing list
> archive
> > at Nabble.com.
> >
>

Re: A JTA EntityManager cannot use getTransaction()

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Updated the website, let me know if it is not better.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-08-06 13:36 GMT+02:00 nicolasduminil <
nicolas.duminil@simplex-software.fr>:

> I would propose the following:
>
> "In the case of some versions of Weld, including but not limited to Weld
> 1.1.36 which comes with JBoss EAP/Wildfly, or OpenWebBeans in BDA mode, you
> have to configure it as a global alternative instead of an alternative in
> beans.xml. That means you have to add either
>
> globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.
> TransactionStrategy
> =org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStra
> tegy
>
> or
>
> globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.
> TransactionStrategy
> =org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStr
> ategy
>
> depending on your BMT/CMT strategy, to the
> /META-INF/apache-deltaspike.properties file"
>
>
>
> --
> View this message in context: http://apache-deltaspike-
> incubator-discussions.2316169.n4.nabble.com/A-JTA-
> EntityManager-cannot-use-getTransaction-tp4663224p4663238.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>

Re: A JTA EntityManager cannot use getTransaction()

Posted by nicolasduminil <ni...@simplex-software.fr>.
I would propose the following:

"In the case of some versions of Weld, including but not limited to Weld
1.1.36 which comes with JBoss EAP/Wildfly, or OpenWebBeans in BDA mode, you
have to configure it as a global alternative instead of an alternative in
beans.xml. That means you have to add either

globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy
=org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStrategy

or

globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy
=org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStrategy

depending on your BMT/CMT strategy, to the
/META-INF/apache-deltaspike.properties file"



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663238.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le 6 août 2016 13:28, "nicolasduminil" <ni...@simplex-software.fr>
a écrit :
>
> I'm sorry but I read too fast the log file. What happened is that another
> exception is raised, but this one is related to my code.
>
> So finally, as opposed to what the documentation is saying, when used in a
> CMT context, the transaction strategy has to be configured *in the
> apache-deltaspike.properties file, and not in beans.xml*. And this is not
> only in the case of OpenWebBeans.
>

Sorry but I fail to see how doc is wrong here. Can you propose a rephrasing
please?

> Haleluiah, I got my answer. This issue is closed now. It wasn't that hard,
> was it ? What a shame that in order to get this simple answer we needed
all
> this smalltalk for nothing !
>
> But thank you anyway. And since I'm here, I would like to signal another
> important error in the documentation. In the Basic Usage chapter of the
JPA
> and the Data module, the  Non EE server and the EE server examples should
be
> inversed. Also, the EE server examples shouldn't try to manuallt close the
> EntityManager as this isn't allowed in a container.
>
> Kind regards,
>
> Nicolas
>
>
>
>
> --
> View this message in context:
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663236.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list
archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by nicolasduminil <ni...@simplex-software.fr>.
I'm sorry but I read too fast the log file. What happened is that another
exception is raised, but this one is related to my code.

So finally, as opposed to what the documentation is saying, when used in a
CMT context, the transaction strategy has to be configured *in the
apache-deltaspike.properties file, and not in beans.xml*. And this is not
only in the case of OpenWebBeans.

Haleluiah, I got my answer. This issue is closed now. It wasn't that hard,
was it ? What a shame that in order to get this simple answer we needed all
this smalltalk for nothing !

But thank you anyway. And since I'm here, I would like to signal another
important error in the documentation. In the Basic Usage chapter of the JPA
and the Data module, the  Non EE server and the EE server examples should be
inversed. Also, the EE server examples shouldn't try to manuallt close the
EntityManager as this isn't allowed in a container.

Kind regards,

Nicolas




--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663236.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by nicolasduminil <ni...@simplex-software.fr>.
Yes, I have seen this note and, what this is saying is that, in my case, I
don't have to configure the transaction strategy in
apache-deltaspike.properties, since I'm not using OpenWebBeans, neither in
BDA mode, nore otherwise.

But to make sure, I've added theis to my META-INF folder:

globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy=org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStrategy

The result is exactly the same:

...
at
org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy.getTransaction(ResourceLocalTransactionStrategy.java:370)
[deltaspike-jpa-module-impl-1.6.1.jar:1.6.1]
...



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663234.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Quoting the doc:

In case of some versions of Weld (or OpenWebBeans in BDA mode), you have to
configure it as a global alternative instead of an alternative in
beans.xml. That means you have to add, for example,
globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy
=org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStrategy
to /META-INF/apache-deltaspike.properties.

Le 6 août 2016 11:41, "nicolasduminil" <ni...@simplex-software.fr>
a écrit :

> "Check your stack:
> org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrate
> gy
> is used for a JTA em so you didnt configure the transaction strategy. "
>
> Oh yes, I did. The post includes the following excerpt:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <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">
>   <alternatives>
>
> <class>org.apache.deltaspike.jpa.impl.transaction.
> ContainerManagedTransactionStrategy</class>
>   </alternatives>
> </beans>
>
> which is supposed to be the way, further to your documentation, to
> configure
> the transaction strategy.
>
>
>
> --
> View this message in context: http://apache-deltaspike-
> incubator-discussions.2316169.n4.nabble.com/A-JTA-
> EntityManager-cannot-use-getTransaction-tp4663224p4663232.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>

Re: A JTA EntityManager cannot use getTransaction()

Posted by nicolasduminil <ni...@simplex-software.fr>.
"Check your stack:
org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy
is used for a JTA em so you didnt configure the transaction strategy. "

Oh yes, I did. The post includes the following excerpt:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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">
  <alternatives>
   
<class>org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStrategy</class>
  </alternatives>
</beans>

which is supposed to be the way, further to your documentation, to configure
the transaction strategy.



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663232.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le 6 août 2016 11:03, "nicolasduminil" <ni...@simplex-software.fr>
a écrit :
>
> "This is very unfair cause you have an issue so you have to show it ..."
> No, it's not at all unfair as I posted the relevant part of the code. But
> nobody looked at it. I could try to provide the minimum code to reproduce
> the issue when I'll have the time. But when I'll have the time, it will
mean
> either that I solved the issue by myself, or that I switched back to
Spring
> Data which has the following advantages:
>   i) works
>   ii) has a full consistent documentation with lots of end-to-end samples
>   iii) provide a very active and proficient forum where people is solution
> and not argument centric
>

Feel free to use spring bit you will get the same output. Point is you dont
use what you configured and without a sample hard to move forward. Also the
doc deals with weld case somewhere - dont have time too to google :p /joke
- and the unfairness you send our way is actually yours.

Check your stack:
org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy
is used for a JTA em so you didnt configure the transaction strategy.

You would have shared a sample which is 15mn of work you would have had the
solution in the half day...

I understand it is frustrating when it doesnt work but being aggressive -
reread, you did and we didnt - doesnt help to solve anything. Same about
"if you dont solve it, ill use something else". We - you and us - dont gain
anything with such a statement excepted being disappointed by each other
which is a shame when the issue is trivial.

> Kind regards,
>
> Nicolas
>
>
>
> --
> View this message in context:
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663230.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list
archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by nicolasduminil <ni...@simplex-software.fr>.
"This is very unfair cause you have an issue so you have to show it ..."
No, it's not at all unfair as I posted the relevant part of the code. But
nobody looked at it. I could try to provide the minimum code to reproduce
the issue when I'll have the time. But when I'll have the time, it will mean
either that I solved the issue by myself, or that I switched back to Spring
Data which has the following advantages:
  i) works
  ii) has a full consistent documentation with lots of end-to-end samples
  iii) provide a very active and proficient forum where people is solution
and not argument centric

Kind regards,

Nicolas 



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663230.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le 6 août 2016 10:11, "nicolasduminil" <ni...@simplex-software.fr>
a écrit :
>
> Gentlemen,
>
> I would like to notice that, while we are having arguments here concerning
> the best manner to post stuff and to answer to them, my issue stays
> unsolved. If I could provide a full project in GitHub, you may be sure
that
> I would but, as any professional knows, this approach is often not
possible,
> for very understandable reasons. Unless the given project is really a
> textbook case, and then it doesn't present issues, as the simplest
textbook
> cases always work. And even if they don't, it doesn't matter much as it's
a
> textbook case.
>

This is very unfair cause you have an issue so you have to show it is an
issue on our side and for that you have to provide a sample reproducing it
- never said to share your banking app.

Side note: doing that you often also find the issue yourself.

> All that to say that it was the first time I was posting to your
marvellous
> forum and, given the way that my posts are received and answered, it will
> certainly be the last one. As per DeltaSpike JPA/Data module, I think I'll
> get back to Spring Data. At least I would have tried.
>

Keep in mind you can pay to get support but not on that forum so people
helping do on their time so you have to drive the effort to lake people
willing to help. We have tons of such examples here or other asf projects
and it always works better when the user drives it instead of saying it
doesnt work cause i saw it in the stack.

> Kind regards,
>
> Nicolas
>
>
>
> --
> View this message in context:
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663228.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list
archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by nicolasduminil <ni...@simplex-software.fr>.
Gentlemen,

I would like to notice that, while we are having arguments here concerning
the best manner to post stuff and to answer to them, my issue stays
unsolved. If I could provide a full project in GitHub, you may be sure that
I would but, as any professional knows, this approach is often not possible,
for very understandable reasons. Unless the given project is really a
textbook case, and then it doesn't present issues, as the simplest textbook
cases always work. And even if they don't, it doesn't matter much as it's a
textbook case.

All that to say that it was the first time I was posting to your marvellous
forum and, given the way that my posts are received and answered, it will
certainly be the last one. As per DeltaSpike JPA/Data module, I think I'll
get back to Spring Data. At least I would have tried.

Kind regards,

Nicolas



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663228.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by Romain Manni-Bucau <rm...@gmail.com>.
@Nicolas: dont get it wrong but we loose a lot of time cause doc is not
read/misread or some copy/paste are done without understanding. Best as a
user is to come and say: this https://github.com/me/demo project doesnt
work as I expect, to run it use "mvn pa ckage tomee:run" - or an embedded
test for instance. Will save a lot of time to all of us - and often saves
minutes for us and days for users.

Le 6 août 2016 08:54, "nicolasduminil" <ni...@simplex-software.fr>
a écrit :

Hi Gerhard,

I'm just curious to understand the motivation that one might have to reply
the way you did to the question of one forum member, who obviously needs
help. Is that anything in my post making you thinking that I didn't read
this documentation before spending some hours in order to get things running
and, finally, deciding to ask for help ?

If you notice something wrong in my post, if you know what the solution to
my issue is, as you seem, why then don't you say it clearly ? Why making me
loosing even more time, to come back to you with this kind of steril
objections ?

And if you don't know what the solution to my issue is, why then spending
your time to send me useless links to the documentation, instead of giving
the chance to other members to provide a real added value ?

Kind regards,

Nicolas



--
View this message in context: http://apache-deltaspike-
incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-
getTransaction-tp4663224p4663226.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by nicolasduminil <ni...@simplex-software.fr>.
Hi Gerhard,

I'm just curious to understand the motivation that one might have to reply
the way you did to the question of one forum member, who obviously needs
help. Is that anything in my post making you thinking that I didn't read
this documentation before spending some hours in order to get things running
and, finally, deciding to ask for help ?

If you notice something wrong in my post, if you know what the solution to
my issue is, as you seem, why then don't you say it clearly ? Why making me
loosing even more time, to come back to you with this kind of steril
objections ?

And if you don't know what the solution to my issue is, why then spending
your time to send me useless links to the documentation, instead of giving
the chance to other members to provide a real added value ?

Kind regards,

Nicolas



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/A-JTA-EntityManager-cannot-use-getTransaction-tp4663224p4663226.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: A JTA EntityManager cannot use getTransaction()

Posted by Gerhard Petracek <ge...@gmail.com>.
hi nicolas,

please have a look at [1].

regards,
gerhard

[1] http://deltaspike.apache.org/documentation/jpa.html#JTASupport



2016-08-05 18:08 GMT+02:00 nicolasduminil <
nicolas.duminil@simplex-software.fr>:

> Greetings,I'm trying to use DeltaSpike 1.6.1 JPA/Data module with JBoss EAP
> 6.4.My repository is as follows:@Repositorypublic interface
> CustomerRepository extends EntityRepository<CustomerEntity,
> BigInteger>{}My
> entity manager producer is as follows:public class EntityManagerProducer{
> @PersistenceContext  private EntityManager em;  @Produces
> @TransactionScoped  public EntityManager createEntityManager()  {    return
> em;  }Notice that I'm not overriding the closeEntityManager() methos as, in
> my context, only the container may close the EntityManager.My service looks
> as follows:@Path("/customers")public class CustomerService{  @Inject
> private CustomerRepository customerRepository;    @POST
> @Consumes("application/json")  public Response createCustomer(Customer
> customer)  {    CustomerEntity customerEntity = new CustomerEntity
> (customer);    customerEntity = customerRepository.save(customerEntity);
> return Response.created(URI.create("/customers/" +
> customerEntity.getId())).build();  }}My persistence.xml looks as
> follows:<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> org.hibernate.ejb.HibernatePersistence    java:jboss/datasources/ExampleDS
> false                                        Last but not least, my
> beans.xml looks as follows:<?xml version="1.0" encoding="UTF-8"
> standalone="yes"?>
> org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStr
> ategy
> Deploying on EAP 6.4.0 raises the following:Caused by:
> java.lang.IllegalStateException: A JTA EntityManager cannot use
> getTransaction()        at
> org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(
> AbstractEntityManagerImpl.java:1019)
> [hibernate-entitymanager-4.2.22.Final-redhat-1.jar:4.2.22.Final-redhat-1]
>      at
> org.jboss.as.jpa.container.AbstractEntityManager.getTransaction(
> AbstractEntityManager.java:498)
> [jboss-as-jpa-7.5.6.Final-redhat-2.jar:7.5.6.Final-redhat-2]    at
> sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source)
> [:1.8.0_65]       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:43)
> [rt.jar:1.8.0_65]       at java.lang.reflect.Method.
> invoke(Method.java:497)
> [rt.jar:1.8.0_65]       at
> org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(
> AbstractBeanInstance.java:45)
> [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]     at
> org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(
> ProxyMethodHandler.java:105)
> [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]     at
> org.jboss.weld.proxies.EntityManager$2068912035$Proxy$_$$_WeldClientProxy.
> getTransaction(EntityManager$2068912035$Proxy$_$$_WeldClientProxy.java)
> [weld-core-1.1.31.Final-redhat-1.jar:]  at
> org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrate
> gy.getTransaction(ResourceLocalTransactionStrategy.java:370)
> [deltaspike-jpa-module-impl-1.6.1.jar:1.6.1]    at
> org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrate
> gy.rollbackAllTransactions(ResourceLocalTransactionStrategy.java:336)
> [deltaspike-jpa-module-impl-1.6.1.jar:1.6.1]    at
> org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrate
> gy.execute(ResourceLocalTransactionStrategy.java:154)
> [deltaspike-jpa-module-impl-1.6.1.jar:1.6.1]    at
> org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner.
> executeTransactional(TransactionalQueryRunner.java:72)
> [deltaspike-data-module-impl-1.6.1.jar:1.6.1]   at
> org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner.executeQuery(
> TransactionalQueryRunner.java:54)
> [deltaspike-data-module-impl-1.6.1.jar:1.6.1]   at
> org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner$
> Proxy$_$$_WeldClientProxy.executeQuery(TransactionalQueryRunner$
> Proxy$_$$_WeldClientProxy.java)
> [deltaspike-data-module-impl-1.6.1.jar:1.6.1]   at
> org.apache.deltaspike.data.impl.handler.QueryHandler.
> process(QueryHandler.java:147)
> [deltaspike-data-module-impl-1.6.1.jar:1.6.1]   ... 38 moreI can't figure
> out
> what the problem might be. The equivalent code, or almost, works properly
> in
> a Java SE environment. Also, not using DeltaSpike JPA/Data but just a
> stateless session bean, works properly. But I would prefer to use the
> repositories. Please help !Many thanks in advance,Nicolas
>
>
>
> --
> View this message in context: http://apache-deltaspike-
> incubator-discussions.2316169.n4.nabble.com/A-JTA-
> EntityManager-cannot-use-getTransaction-tp4663224.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>