org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError)

前端 未结 5 696
余生分开走
余生分开走 2021-01-21 10:14

I am trying out some very basic webservice. I get this exception everytime I try to return the Prtnr object.

Uncaught exception thrown in one of the service met         


        
5条回答
  •  面向向阳花
    2021-01-21 10:49

    The infinite recursion is due to the following: Class Prtnr contains Set prtnrGeoInfos and each PrtnrGeoInfo contains PrtnrGeoInfoId id which in turn contains Prtnr partner.

    Thus, Prtnr -> PrtnrGeoInfo ->PrtnrGeoInfoId ->Prtnr, is causing a cyclic dependency which is a problem for Jackson when it is trying to do the POJO Mapping.

    You need to remove this cyclic dependency to fix this exception.

提交回复
热议问题