• 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

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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic