cm_api icon indicating copy to clipboard operation
cm_api copied to clipboard

Java Client is using deprecated Jackson2 object references in the class ApiObjectMapper

Open scottreisdorf opened this issue 9 years ago • 2 comments

The project uses an older version of Jackson2 and references the deprecated AnnotationIntrospector$Pair class. This causes problems if you are trying to use this client with a project that has a Jackson2 version greater than 2.2

The class ApiObjectMapper should reference new AnnotationIntrospectorPair( ...) not Pair(...)

To get this to work you also need to update the cxf.verision to 2.7.8 Below are the changes to allow usage of Jackson2 versions 2.3 or later:

pom.xml

  <properties>
    <cxf.version>2.7.8</cxf.version>
    <guava.version>14.0</guava.version>
    <jackson2.version>2.3.4</jackson2.version>
    <joda.version>2.1</joda.version>
    <junit.version>4.11</junit.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <test.redirectToFile>true</test.redirectToFile>
    <privateClassPath>com.cloudera.api.shaded</privateClassPath>
  </properties>

ApiObjectMapper constructor

  public ApiObjectMapper() {
    // Print the JSON with indentation (ie. pretty print)
    configure(SerializationFeature.INDENT_OUTPUT, true);
    // Allow JAX-B annotations.
    setAnnotationIntrospector(
       new AnnotationIntrospectorPair(
            getSerializationConfig().getAnnotationIntrospector(),
            new JaxbAnnotationIntrospector(getTypeFactory())));
    // Make Jackson respect @XmlElementWrapper.
    enable(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME);
    // Print all dates in ISO8601 format
    setDateFormat(makeISODateFormat());
  }

scottreisdorf avatar Oct 13 '15 00:10 scottreisdorf

Same here. Hope Cloudera can fix it in a future path version.

stevenchen3 avatar Jun 29 '16 07:06 stevenchen3

did you find a workaround to that problem, assuming i'd like to use a newer version of jackson?

barakschoster avatar Sep 01 '16 10:09 barakschoster