Does anyone know if it's possible to make CMP JTA work on plain CDI beans? The goal is just to inject a DAO bean (which is NO EJB) into a JSF bean, annotate a method with some kick-ass annotation and make it work out of the box. Some thing like this :
@Named
public class ClusterController {
@Inject
private ClusterDAO clusterDAO;
/**
* A simple proxy method
* @param cluster cluster to be saved to the DB
*/
@Transactional(value = Transactional.TxType.REQUIRES_NEW)
public void createCluster(Cluster cluster) {
clusterDAO.saveEntity(cluster);
}
}
This @Transactional(value = Transactional.TxType.REQUIRES_NEW)
does not do the trick (I'm using JBOSS EAP 6). I get :
Caused by: javax.persistence.TransactionRequiredException: JBAS011469: Transaction is required to perform this operation (either use a transaction or extended persistence context)
at org.jboss.as.jpa.container.AbstractEntityManager.transactionIsRequired(AbstractEntityManager.java:692) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.jpa.container.AbstractEntityManager.persist(AbstractEntityManager.java:562) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]