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

ParameterizedType#getActualTypeArguments() classes not added to the JAXBContext for JAX-RS providers

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6.1
    • 2.5.5, 2.6.2, 2.7
    • JAX-RS
    • None
    • Unknown

    Description

      Take a parameterized class like PageResult<T> :

      --------------------------------------------------------
      @XmlRootElement
      @XmlAccessorType(XmlAccessType.FIELD)
      public class ResultPage<T> {

      private List<T> content;

      public List<T> getContent()

      { return content; }

      public void setContent(List<T> content)

      { this.content = content; }

      }
      --------------------------------------------------------

      And take a service which uses this parameterized class :

      --------------------------------------------------------

      public interface UserService

      { @GET public PageResult<User> findUsers(); @GET public PageResult<Role> findRoles(); }

      --------------------------------------------------------

      When provider create JAXBContext (eg: JSONProvider) for this interface, only PageResult class is added to the JAXBContext and we need declare the 2 classes

      -------------------------------------------------------------

      <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
      <property name="singleJaxbContext" value="true" />
      <property name="extraClass">
      <list>
      <value>User</value>
      <value>Role</value>
      </list>
      </property>
      </bean>
      -------------------------------------------------------------

      This mean can be boring, because as soon as you add new domain class, you must modify too this declaration.

      In my case I cannot use XmlSeeAlso because PageResult belongs to another Java Project (Spring Data) and it can be used with any domain classes.

      To fix this problem, the JAX-RS CXF provider should populate the JAXBContext with PageResult, A and B instead of just with PageResult.

      The attached patch manage this case.

      Attachments

        1. cxf-patch.txt
          12 kB
          Angelo
        2. src.zip
          3 kB
          Angelo

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            angelo Angelo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: