Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
1.6.1
-
None
-
Wildfly 10.1.0, RESTeasy 3.0.19, CDI 1.2, Ubuntu 16.04
Description
Hello,
In a JAX-RS service, using RestEasy 3.0 on Wildfly 10.1, I have the following producer:
@ApplicationScoped
public class EntityManagerProducer
{
@PersistenceContext(unitName = "customers")
private EntityManager em;
@Produces
@Default
@RequestScoped
public EntityManager createEntityManager()
public void dispose(@Disposes @Default EntityManager entityManager)
{ if (entityManager.isOpen()) entityManager.close(); }}
The following end-point:
@Inject
private CustomerManagementRepository repo;
..............
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Transactional
public Response createCustomer(Customer customer)
raises the exception:
14:57:53,121 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /customer-management/services/customers: org.jboss.resteasy.spi.UnhandledException: javax.persistence.TransactionRequiredException: WFLYJPA0060: Transaction is required to perform this operation (either use a transaction or extended persistence context)
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:77)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:220)
................
Here above the CustomerManagerRepository is:
@Repository
public interface CustomerManagementRepository extends EntityRepository<Customer, BigInteger>
I also have the following beans.xml file:
<?xml version="1.0"?>
<beans bean-discovery-mode="annotated" version="2.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd">
<alternatives>
<class>org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStrategy</class>
</alternatives>
</beans>
What I'm doing wrong here ?