Estou programando um WebService (JAX-WS e Glassfish) mas estou recebendo a exceção javax.persistence.TransactionRequiredException. Segue o código
Classe Web Service
package Produto;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@WebService
public class ProdutoWebService {
@PersistenceContext
private EntityManager em;
@WebMethod
public void incluir(
@WebParam(name="produto") Produto produto) {
try {
em.persist(produto);
em.flush();
}
catch(Exception exception) {
System.out.println(exception.toString());
}
}
}
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="webservice">
<jta-data-source>jdbc/webserviceResource</jta-data-source>
<class>Produto.Produto</class>
<class>Produto.ProdutoWebService</class>
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
</properties>
</persistence-unit>
</persistence>
Por favor, me ajudem. Valeu.