Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Tomcat EE 1.7.3 with Java CDI transaction manangement

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!