Javax/persistence/Persistence problem using JPA with CXF

Asked

Viewed 144 times

0

I am 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 arrow a 'person' and a 'listGato' from this following 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 did a test class just to test the JPA and it’s working perfectly. I also tested the WS with Soapui and it’s working perfectly. The problem then lies with the consumer. Where am I going wrong?

  • Hello André. Welcome to Sopt. I’m glad your difficulty has been resolved. But please note that this site is not a forum. Do not edit the question to put "SOLVED". Instead, add an answer yourself with the solution, as a way to help others in the future. If you haven’t done it yet, I suggest you read [help].

  • 1

    Thanks Luiz, I haven’t read it yet and I will do it before my next post/ help to another user. Thank you very much.

  • Not at all. : ) But, even so, you could already do this in this question. Edit it again to take the "solved" part (the colleague @Diegofelipe already made it just for the title) and create yourself a response with your conclusion. In fact, if the problem has indeed been solved, mark your own answer as "accepted", so the question does not appear as a pending answer.

1 answer

0


RESOLVED!
The program is written perfectly for the proposal but I put the libraries in the wrong place, thus working only locally.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.