I'm facing an error when I try to consume a web service that is using JPA (Eclipse-link) to insert data into the database.
Classes Entity:
@Entity
@Table(name = "gato")
public class GatoPersistente implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "nick")
private String nick;
@ManyToMany(mappedBy = "gatos")
private List<PessoaPersistente> pessoas;
// Getters e Setters
@Entity
@Table(name = "pessoa")
public class PessoaPersistente implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "nome")
private String nome;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "relacao_pessoa_gato", joinColumns = { @JoinColumn(name = "id_pessoa") }, inverseJoinColumns = { @JoinColumn(name = "id_gato") })
private List<GatoPersistente> gatos;
// Getters e Setters
WS
@WebService(targetNamespace = "http://produtor.ws.fronteira/", portName = "ExercicioManyToManyWSPort", serviceName = "ExercicioManyToManyWSService")
public class ExercicioManyToManyWS {
@WebMethod(operationName = "salva", action = "urn:Salva")
public boolean salva(PessoaPersistente pessoa,
List<GatoPersistente> listagato) {
return ControladorPessoaGato.salva(pessoa, listagato);
}
}
And finally the consumer facade:
@Override
public boolean salva(PessoaPersistente pessoa, List<GatoPersistente> listaGato) {
ExercicioManyToManyWSService service = new ExercicioManyToManyWSService();
ExercicioManyToManyWS port = service.getExercicioManyToManyWSPort();
return port.salva(pessoa, listaGato);
}
When I create a test class that just pushes a 'person' and a 'Catlist', it gives this error:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: javax/persistence/Persistence
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:157)
at com.sun.proxy.$Proxy27.salva(Unknown Source)
at fronteira.ws.consumidor.FacadeConsumidorCXF.salva(FacadeConsumidorCXF.java:12)
at controlador.ControladorDeTeste.main(ControladorDeTeste.java:31)
Caused by: org.apache.cxf.binding.soap.SoapFault: javax/persistence/Persistence
I've done a test class just to test the JPA and it's working perfectly. I also tested WS with SoapUI and it's working perfectly. The problem then lies in the consumer side. Where am I going wrong?