Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with Camel and Jackson Dependency

I'm facing an issue with the latest version of Camel and a REST DSL route. The full code can be found and run from here: https://github.com/mikevoxcap/nvisia-catalog-camel-service. I'm getting an exception when I try to run the route, underlying cause below:

Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.introspect.AnnotatedMember.getType()Lcom/fasterxml/jackson/databind/JavaType;
....
at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:926)
    at org.apache.camel.component.jackson.JacksonDataFormat.marshal(JacksonDataFormat.java:154)
    at org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:69)

My question is, which version of Jackson should I be targeting to no longer receive this exception.

I'm bringing in the following dependencies:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <spring.boot.version>1.3.5.RELEASE</spring.boot.version>
    <camel.version>2.17.1</camel.version>
    <java.version>1.8</java.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring.boot.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-boot</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jackson</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-servlet</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-swagger-java</artifactId>
        <version>${camel.version}</version>
    </dependency>

    <!-- Testing -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-test-spring</artifactId>
        <version>${camel.version}</version>
        <scope>test</scope>
    </dependency>   
</dependencies>

After doing some searching on the exception I received, several people have run into this issue when it comes to version conflict. I noticed that the camel-jackson library is bringing in jackson-module-jaxb-annotations 2.7.2, but the remaining jackson libraries are at 2.6.6. I tried excluding jackson-module-jaxb-annotations 2.7.2 and then directly including 2.6.6, but that still resulted in the exception.

My route is relatively simple:

  // Definition of the get catalog item endpoint
  rest("/catalogItem").
        // This is a GET method call for getting a catalog item by ID.
  get("{id}").
        // Description of what this method does
        description("Retrieve a catalog item by ID").
        // Define the output type that will be returned from this method
        outType(CatalogItem.class)
        // Define where the message is routed to as a URI. Here we use a
        // Spring Bean and define the bean method to invoke. Note that Camel
        // has converted the ID placeholder from the URL into a header
        // entry.
        .to("bean:catalogService?method=getCatalogItem(${header.id})");

My object being used as the JSON type is also pretty simple:

public class CatalogItem {

   private int id;
   private double price;
   private String catalogItemType;
   private List<CatalogItemAttribute> attributes;

public class CatalogItemAttribute {

   private String attributeName;
   private String attributeValue;
like image 299
Michael Hoffman Avatar asked Sep 15 '25 05:09

Michael Hoffman


1 Answers

While I haven't found anything official from Camel, it looks like this will resolve itself once Spring Boot 1.4 is released as it will be move to support Jackson 2.7. In the meantime, I updated my dependencies as noted below. I added exclusions for the jackson-annotations, jackson-core and jackson-databind libraries to the spring-boot-starter-web, spring-boot-starter-actuator, camel-jackson and camel-swagger-java dependencies. Then I specified the three jackson dependencies with 2.7.2.

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>jackson-annotations</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jackson-core</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jackson-databind</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>jackson-databind</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-boot</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jackson</artifactId>
        <version>${camel.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>jackson-annotations</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jackson-core</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jackson-databind</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-servlet</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-swagger-java</artifactId>
        <version>${camel.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>jackson-annotations</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jackson-core</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jackson-databind</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <artifactId>jackson-annotations</artifactId>
        <groupId>com.fasterxml.jackson.core</groupId>
        <version>2.7.2</version>
    </dependency>
    <dependency>
        <artifactId>jackson-core</artifactId>
        <groupId>com.fasterxml.jackson.core</groupId>
        <version>2.7.2</version>
    </dependency>
    <dependency>
        <artifactId>jackson-databind</artifactId>
        <groupId>com.fasterxml.jackson.core</groupId>
        <version>2.7.2</version>
    </dependency>

    <!-- Testing -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-test-spring</artifactId>
        <version>${camel.version}</version>
        <scope>test</scope>
    </dependency>   
</dependencies>
like image 194
Michael Hoffman Avatar answered Sep 16 '25 20:09

Michael Hoffman