This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Use of @XmlTransient with REST Webservices  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following 2 business objects:
public class Artifact {
private Museum museum;
// other properties

public Museum getMuseum() {
return museum;

// getters and setters for other properties

public class Museum {
private Set<Artifact> artifactList;
// other properties

public Set<Artifact> getArtifactList() {
return artifactList;

// getters and setters for other properties

When I try to get a Museum by specifying the museum_id or when I try to get a Artifact by specifying the artifact_id, I am getting the following exception:
Aug 17, 2013 8:21:16 PM com.sun.jersey.spi.container.ContainerResponse logException
SEVERE: Mapped exception to response: 500 (Internal Server Error) javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML: -> ->]
at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(
at com.sun.jersey.spi.container.ContainerResponse.write(
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(
at com.sun.jersey.spi.container.servlet.WebComponent.service(
at com.sun.jersey.spi.container.servlet.ServletContainer.service(
at com.sun.jersey.spi.container.servlet.ServletContainer.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
at Source)

I was able to resolve this issue by specifying the @XmlTransient for the above mentioned getter methods in the given Museum and Artifact class. But after specifying this, I could not get the completely populated business objects i.e if I queried an artifact for a given id, the museum field in the returned object was null. Similarly when I tried to query a museum for a given id, the list of artifacts returned were null.

I am using Hibernate for fetching these objects from database. How do I resolve this ? I want to get the completely populated business objects.

Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Enterprise Java integration with Delphi and Free Pascal applications - new release 2019.02
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!