• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic