Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Tomcat EE 1.7.3 with Java CDI transaction manangement

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I want to use Java CDI with transaction management but i am getting below exception
javax.persistence.TransactionRequiredException

Use case is
1. I have one DAO Impl class where i am injecting Entity manager
@PersistenceContext
protected EntityManager entityManager;

2. I have one service class annotated with @Named annotation.

Now in service class, i have one method, which i have tried to annoted with Transaction annotation


@Transactional(value=Transactional.TxType.REQUIRED)
public String printMethod() {

List<ClientStatus> lst = clientStatusDao.getAll();

for (ClientStatus clientStatus : lst) {
System.out.println("----------------- clientStatus ------------ " + clientStatus.clientStatusDesc);
if(clientStatus.getClientStatus().equals("A")) {
System.out.println("----------------- changing client status ------------ ");
clientStatus.setClientStatusDesc("Activ");
clientStatusDao.updateStatus(clientStatus);
}
}
return s;

}


Here i am able to fetch the records from the database but on update i am getting below exception


javax.persistence.TransactionRequiredException
org.apache.openejb.persistence.JtaEntityManager.assertTransactionActive(JtaEntityManager.java:116)
org.apache.openejb.persistence.JtaEntityManager.merge(JtaEntityManager.java:156)

I am not using EJB. Some blogs i read that Java EE 7 along with JTA 1.2 does not require EJB for the transaction.

Not able to understand, where i am doing mistake.

Please help,

Regards,
Sunil
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have the same problem (error) but wih with EJB's TOMEE 1.7.4 + EclipseLink + CDI + MySql. Did you find some  decision?
 
I didn't say it. I'm just telling you what this tiny ad said.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic