users@glassfish.java.net

RE: Infinite XML Loop

From: Kenneth Clark <kenneth_at_rabiddog.co.za>
Date: Mon, 13 Aug 2007 07:14:31 +0200

Hi

I can think of any other reason as all I am doing is executing a query.

The service is defined as

@WebMethod
public List<AccountType> queryAccountTypeFindAll() {
  return em.createNamedQuery("AccountType.findAll").getResultList();
}

The AccountType object has a reference to an a Collection of type
EntityAccountInformation and each instance of EntityAccountInformation has a
single reference to AccountType.

I don't know what I have done wrong here. Never seen this before to be
honest (this error that is) will dig deeper and see what I come across.

Thanks for the input thus far

Kenneth Clark
Solution Architect / Lead Developer
Rabid Dog Labs

Tel: +27 11 475 7409
Mobile: +27 82 500 5090
Email: kenneth_at_rabiddog.co.za
Web: http://www.rabiddog.co.za
-----Original Message-----
From: Marina.Vatkina_at_Sun.COM [mailto:Marina.Vatkina_at_Sun.COM]
Sent: Friday, August 10, 2007 20:23
To: users_at_glassfish.dev.java.net
Subject: Re: Infinite XML Loop

Are you sure that the exception comes from the query? It seems like an xml
processing error.

thanks,
-marina

Kenneth Clark wrote:
> I am not understanding what you mean unfortunately.
>
> If I remove references to objects inside objects I effectively break my
> model. How would I go about setting references to null if I am doing a
> straight "Select o From AccountType o"?
>
> Unless there is a better mechanism to select all the objects I am at a
loss
> here.
>
> Kenneth Clark
> Solution Architect / Lead Developer
> Rabid Dog Labs
>
> Tel: +27 11 475 7409
> Mobile: +27 82 500 5090
> Email: kenneth_at_rabiddog.co.za
> Web: http://www.rabiddog.co.za
> -----Original Message-----
> From: Sanjeeb.Sahoo_at_Sun.COM [mailto:Sanjeeb.Sahoo_at_Sun.COM] On Behalf Of
> Sahoo
> Sent: Friday, August 10, 2007 13:32
> To: users_at_glassfish.dev.java.net
> Subject: Re: Infinite XML Loop
>
> That exception typically comes from JAXB marshaling code when it detects
> a cycle in the object graph. Are you returning the object from a web
> service? Your in-memory object probably has the bidirectional references
> set up, this can happen if you traverse the relationships in your code.
> So, instead of relying on fetch type, you should explicitly cut the
> cycles in the graph by setting some references null.
>
> Thanks,
> Sahoo
>
> Kenneth Clark wrote:
>
>>Hi guys
>>
>>I have a bi-directional relationship and everytime I try and fetchAll
>>I am getting the error
>>
>>“com.sun.istack.SAXException2: A cycle is detected in the object graph.
>
> This will cause infinitely deep XML:”
>
>>The mapping in the AccountType class is:
>>
>>@OneToMany(mappedBy = "accountType", fetch=FetchType.LAZY)
>>
>>private Collection<EntityAccountInformation>
>>entityAccountInformationCollection;
>>
>>And the mapping in the EntityAccountInformation is
>>
>>@ManyToOne
>>
>>@JoinColumn(name = "account_type_id", referencedColumnName = "id")
>>
>>private AccountType accountType;
>>
>>Do I have to remove the bidirectional relationship to resolve this?
>>Why is it ignoring the FetchType?
>>
>>I enabled the toplink.weaving property (read that it might stop this)
>>
>><property name="toplink.weaving" value="true"/>
>>
>>But nothing seems to be helping.
>>
>>Any feed back would be great
>>
>>Thanks
>>
>>Kenneth Clark
>>*Solution Architect / Lead Developer**
>>**Rabid Dog Labs*
>>
>>
>>*Tel:* +27 11 475 7409
>>
>>*Mobile**:* +27 82 500 5090
>>*Email:* kenneth_at_rabiddog.co.za <mailto:kenneth_at_rabiddog.co.za>
>>*Web: *_http://www.rabiddog.co.za <http://www.rabiddog.co.za/>_
>>
>>
>>No virus found in this outgoing message.
>>Checked by AVG Free Edition.
>>Version: 7.5.476 / Virus Database: 269.11.11/944 - Release Date:
>>2007/08/09 14:44
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.11/944 - Release Date:
2007/08/09
> 14:44
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.11/944 - Release Date:
2007/08/09
> 14:44
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.15/949 - Release Date: 2007/08/12
11:03
 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.15/949 - Release Date: 2007/08/12
11:03