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

Json API client does not work with Jackson 2.2

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.5.11
    • Invalid
    • JAX-RS
    • None
    • Unknown

    Description

      JacksonJsonProvider in Jackson 2.2 changes the signature to:

       JacksonJsonProvider extends ProviderBase<JacksonJsonProvider, ObjectMapper, JsonEndpointConfig, JsonMapperConfigurator>
      

      That means it'll never get picked as a candidate for a message reader, because ProviderFactory#handleMapper has this:

      Class<?> mapperClass =  ClassHelper.getRealClass(em.getProvider());
      Type[] types = getGenericInterfaces(mapperClass);
      for (Type t : types) {
          if (t instanceof ParameterizedType) {
              ParameterizedType pt = (ParameterizedType)t;
              Type[] args = pt.getActualTypeArguments();
              for (int i = 0; i < args.length; i++) {
                  Type arg = args[i];
                  if (arg instanceof TypeVariable) {         // <------ Always fail
                      TypeVariable var = (TypeVariable)arg;
                      Type[] bounds = var.getBounds();
      

      And the symptom is that my API client (which has a dependency on Jackson 2.2.2) errors out like this:

      Caused by: javax.ws.rs.WebApplicationException: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"items"). Expected elements are <{}cluster>,<{}clusterList>,<{}clusterRef>,<{}config>,<{}configList>,<{}healthCheck>,<{}parcel>,<{}role>,<{}roleConfigGroup>,<{}roleConfigGroupRef>,<{}roleTypeConfig>,<{}service>,<{}serviceConfig>,<{}serviceRef>
      	at org.apache.cxf.jaxrs.provider.AbstractJAXBProvider.handleExceptionEnd(AbstractJAXBProvider.java:602)
      	at org.apache.cxf.jaxrs.provider.AbstractJAXBProvider.handleJAXBException(AbstractJAXBProvider.java:614)
      	at org.apache.cxf.jaxrs.provider.JSONProvider.readFrom(JSONProvider.java:248)
      

      Note the last line. It should've used JacksonJsonProvider instead.

      Attachments

        Activity

          People

            Unassigned Unassigned
            bcwalrus bc Wong
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: