the program under this particular environment: EJB3.0 + JPA + jersey Web Service
First Entity :
@Entity
@Table(name = "student_by_test_yao")
public class StudentTest implements Serializable {
    @Id
    @GeneratedValue
    private Integer id;
    private String name;
    @ManyToOne
    @JoinColumn(name = "class_id")
    private ClassTest classes;
    public StudentTest() {}
}
Second Entity:
@Entity
@Table(name = "class_by_test_yao")
public class ClassTest implements Serializable{
    @Id
    @GeneratedValue
    private Integer id;
    private String name;
    @OneToMany(mappedBy = "classes",cascade = CascadeType.ALL, fetch=FetchType.EAGER)
    private List<StudentTest> students;
    public ClassTest() {}
}
When I get the ClassTest 's students list. Exception is:
com.fasterxml.jackson.databind.JsonMappingException:
Infinite recursion (StackOverflowError)
If I change the fetch FetchType.LAZY the Exception is:
org.hibernate.LazyInitializationException: 
failed to lazily initialize a collection of role: 
cn.gomro.mid.core.biz.goods.test.ClassTest.students, 
could not initialize proxy - no Session
How to resolve my problems?
 
     
     
     
     
     
    