Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JAX-WS based WS using EntityManager to persist data to DB  RSS feed

 
C Shinde
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am creating some test WebServices.
This service uses CM Entity Manager, so I have the following line of code:


Now since this in CM Entity Manager with JTA transaction, I dont need to explicitly use UserTransaction as the Container will manage the transactions.
When I call this WS I get an error like
.

I tried using the UserTransaction and explicitly tried comiting the transaction and it did not give this exception but when I checked the DB there were no records, I have read that I should not be using explicit transactions for CM Entity manager.

Also I am attaching my persistent.xml file

My tables are already present.

Any help is appreciated. Thanks in advance.
 
C Shinde
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I think I got the answer but partially...

Here the link where I read about the solution :

webpage

But I am not sure why I cannot inject the EntityManager directly into a web application/Service, other than the Syncronization issue?

Here he says that I should use the EntityManagerFactory that is ThreadSafe against the EntityManager, so basically use Application Managed Entity Manager.

Please share your comments.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!