• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat EE 1.7.3 with Java CDI transaction manangement  RSS feed

 
xsunil kumar
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
 
Yordan Voynov
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!