1

We're having an issue when using jackson-databind in a JBoss EAP environment. We usually deploy to Tomcat 8, which works flawlessly. Jackson it self deserializes objects normally, however when: mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); is executed we receive this error:

13:18:26,170 ERROR java.lang.NoSuchFieldError: SNAKE_CASE

I paraphrased the error quite a bit, but it seems that JBoss cannot find the jackson-databind dependency. We verified that the class is indeed in the deployed WAR file. This is what we have in our POM:

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

When we copy the Java class into our code base, it works flawlessly on JBoss but that is obviously not ideal. Has anyone seen JBoss not find a dependency before?

skylerl
  • 4,030
  • 12
  • 41
  • 60
  • We ended up finding a working solution here: https://stackoverflow.com/questions/37060294/wildfly-9-how-do-i-exclude-jackson – skylerl Oct 02 '17 at 16:05

1 Answers1

1

Jackson databind is already present as JBoss module, therefore your exception is a result of conflicting lib loading during your app deployment.
To be more precise, Jackson databind is located at jboss-eap-7.0\modules\system\layers\base\com\fasterxml\jackson\core\jackson-databind\main\ at version 2.5.4. Therefore you should set you maven dependency to <scope>provided</scope>.
However, there are several changes between 2.5.4 and 2.8.9 that you requested. You do not mention what Jackson features do you intend to use, but at the very least, you can not use SNAKE_CASE as it does not yet exist in the older version. One option is that you can fallback to the older variant CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES. If that is not acceptable, you will have to customize the JBoss class loading using jboss-deployment-structure.xml. With this descriptor, you can choose to exclude the jackson databind provided by JBoss modules and then you can bundle the jackson lib with your deployment. You can find more info in JBoss/Wildfly wiki.

yntelectual
  • 3,028
  • 18
  • 24