Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5073

endless recursion in creating JAX-RS client proxy

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      I'm having a problem creating a JAX-RS client proxy with CXF version 2.7.5.
      I wrote a simple sample application designed with a resource model that is built up of "ProductResource"s which contain "parts" which are also "ProductResource"s ("PartsResource" being a collection wrapper resource).
      Creating the client proxy for these resources gets into an endless recursion and eventually fails with a stack overflow. I assume this is related to the loop among the resources (ProductResource -> PartsResource -> ProductResource).

      When this loop is "immediate", i.e. ProductResource directly references its part ProductResource's without the separate "PartsResource" collection wrapper, the client proxy creation does not get into the endless recursion and succeeds.
      On the server side, there are no problems with either resource model.

      @XmlRootElement(name = "ProductResource")
      @Produces("application/json")
      public interface IProductResource {
      @Path("/parts")
      public IPartsResource getParts();

      ...
      }

      @XmlRootElement(name = "PartsResource")
      @Produces("application/json")
      public interface IPartsResource {
      @Path("/

      {i}

      /")
      public IProductResource elementAt(@PathParam("i") String i);

      ...
      }

      And the line that gets into the endless recursion (again simplified a bit):
      IProductResource productResource = JAXRSClientFactory.create("http://localhost:9000", IProductResource.class);

      The relevant part of the stack trace, showing the endless recursion:
      ...
      at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:263)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:242)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:263)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:242)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:263)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:242)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:263)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:242)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:263)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:242)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:263)
      at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:242)
      ...

      Best regards,
      Andras

      Attachments

        1. drProduct.zip
          19 kB
          Andras Istvan Nagy

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            ainagy Andras Istvan Nagy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: