Skip to content

Add a note about Jackson annotation library clash in Wildfly #4734

@mcollovati

Description

@mcollovati

When using Vaadin 25 in Wildfly, it could happen that the application fails at deployment or runtime because of an incompatibility with the Jackson annotation artifact version.

Wildfly adds jackson 2.x to each deployment as part of the default jaxrs subsystem. This causes issues with Vaadin 25 if the Jackson annotation dependency is older than the one expected by Jackson 3 (used by Vaadin).

07:41:44,960 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /push/: java.lang.NoSuchFieldError: Class com.fasterxml.jackson.annotation.JsonFormat$Shape does not have member field 'com.fasterxml.jackson.annotation.JsonFormat$Shape POJO'
        at deployment.push.war//tools.jackson.databind.ser.BasicSerializerFactory.buildEnumSerializer(BasicSerializerFactory.java:1071)
        at deployment.push.war//tools.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:241)
        at deployment.push.war//tools.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:182)
        at deployment.push.war//tools.jackson.databind.SerializationContext._createAndCachePropertySerializer(SerializationContext.java:1027)
        at deployment.push.war//tools.jackson.databind.SerializationContext.findPrimaryPropertySerializer(SerializationContext.java:697)
        at deployment.push.war//tools.jackson.databind.ser.bean.BeanSerializerBase.resolve(BeanSerializerBase.java:311)
        at deployment.push.war//tools.jackson.databind.ser.UnrolledBeanSerializer.resolve(UnrolledBeanSerializer.java:155)
        at deployment.push.war//tools.jackson.databind.ser.SerializerCache.addAndResolveNonTypedSerializer(SerializerCache.java:216)
        at deployment.push.war//tools.jackson.databind.SerializationContext._createAndCacheUntypedSerializer(SerializationContext.java:975)
        at deployment.push.war//tools.jackson.databind.SerializationContext.findValueSerializer(SerializationContext.java:774)
        at deployment.push.war//tools.jackson.databind.SerializationContext.findTypedValueSerializer(SerializationContext.java:586)
        at deployment.push.war//tools.jackson.databind.ser.SerializationContextExt.valueToTree(SerializationContextExt.java:185)
        at deployment.push.war//tools.jackson.databind.ObjectMapper.valueToTree(ObjectMapper.java:1365)
        at deployment.push.war//com.vaadin.flow.server.communication.UidlWriter.dependencyToJson(UidlWriter.java:252)

The current solution to the problem is to add a jboss-deployment-structure.xml descriptor to the application, which contains an explicit exclusion for the Jackson annotation modules or the whole jaxrs subsytem.
To be noted that the module exclusion works only starting with Widlfly 37; for previous releases the jaxrs subsytem must be excluded.

This is mentioned in the release notes for Vaadin 25, but it would be good to add a note also on the Vaadin CDI add-on documentation, since Wildfly is most likely to be used with that add-on.

<jboss-deployment-structure>
    <deployment>
        <!-- Wildfly 37+ -->
        <exclusions>
            <module name="com.fasterxml.jackson.core.jackson-annotations"/>
        </exclusions>
        <!-- Wildfly less than 37 -->
        <exclude-subsystems>
            <subsystem name="jaxrs" />
        </exclude-subsystems>
    </deployment>
</jboss-deployment-structure>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    🅿️Parking lot

    Status

    Next for Dev. Team

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions