File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Problem with Web Service Response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Problem with Web Service Response" Watch "Problem with Web Service Response" New topic

Problem with Web Service Response

Abhishek Uppala

Joined: May 27, 2009
Posts: 10


I am new to developing Web Services and have run into a problem with my web service. I have a web service exposed using Aegis mapping. The service implementation calls business logic which uses Hibernate to retrieve a record from DB. All is working fine from Hibernate implementation but when the web service is returning the response, the getter() on the object is being called recursively. Kindly help if I am doing something wrong.

Here is the code snippet

public Interface ItemService(){
public Item getItemList();

public class ItemServiceImpl() implements ItemService{
public Item getItemList(){
return ItemServiceManager.getItems();

public class ItemServiceManager(){
public static Item getItems(){
SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();

public class Item {

@Column(name = "Id")
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "ItemName")
private String itemName;
@Column(name = "ItemCategory")
private String itemCategory;

private Set<OrderItem> orderItems;

public Long getId() {
return id;

public void setId(Long id) { = id;

public String getItemName() {
return itemName;

public void setItemName(String itemName) {
this.itemName = itemName;

public String getItemCategory() {
return itemCategory;

public void setItemCategory(String itemCategory) {
this.itemCategory = itemCategory;

public Set<OrderItem> getOrderItems() {
return orderItems;

public void setOrderItems(Set<OrderItem> orderItems) {
this.orderItems = orderItems;


public class OrderItem {

@Column(name = "OrderItemId")
@GeneratedValue(strategy = GenerationType.AUTO)
private Long orderItemId;
@JoinColumn(name = "OrderId")
private Order order;

@JoinColumn(name = "ItemId")
private Item item;

public Long getOrderItemId() {
return orderItemId;

public void setOrderItemId(Long orderItemId) {
this.orderItemId = orderItemId;

public Order getOrder() {
return order;

public void setOrder(Order order) {
this.order = order;

public Item getItem() {
return item;

public void setItem(Item item) {
this.item = item;

On debugging, I observed that getOrderItems() in Item class and getItem() in OrderItem class are called recursively

Kindly help


Abhishek Uppala
I agree. Here's the link:
subject: Problem with Web Service Response
It's not a secret anymore!