• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic