users@jax-ws.java.net

Circular relationship problems with jaxb and jax-ws

From: Fernando Parisotto <fernando.parisotto_at_gmail.com>
Date: Mon, 30 Oct 2006 17:18:48 -0300

Hy every one,
I have 2 classes,

-------------------------------------------------------------------
package net.uniplac.tcc.segurancaws.model;
// imports...
public class Categoria implements Serializable {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;

    @Column(nullable=false, unique = true)
    private String nome;

    private String unidade;

    @OneToMany(mappedBy = "categoria")
    private Set<Produto> produtos;

    // gets and sets

}
---------------------------------------------------------------
and
---------------------------------------------------------------
package net.uniplac.tcc.segurancaws.model;
public class Produto implements Serializable {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;

    private String nome;

    private Double precoUnitario;

    private int qdtEstoque;

    @ManyToOne
    private Categoria categoria;

    // gets and sets

}

And I have some serios problems to expose this classes into a Web Services.

I have this exceptions:

javax.xml.soap.SOAPException: javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.SAXException2: A cycle is detected in the object graph. This
will cause infinitely deep XML: Mogno -> Door-> Mogno]
java.lang.RuntimeException: javax.xml.soap.SOAPException:
javax.xml.soap.SOAPException: javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.SAXException2: A cycle is detected in the object graph. This
will cause infinitely deep XML: Mogno -> Door-> Mogno]

What can I do to avoid this circular relation erros on marshal my object
graph?

Please help, thanks for all.
-- 
Fernando Luiz Parisotto