Issue
When deploying a custom REST application built with Liferay's REST Builder, the Swagger UI fails to load for the custom endpoint. The logs show an error similar to the following:
java.lang.IllegalArgumentException: Conflicting setter definitions for property "..."- The exception details a conflict between two setter methods in a generated DTO class: one for the expected data type (e.g.,
java.lang.Integer) and another forcom.liferay.petra.function.UnsafeSupplier. - This issue typically appears after upgrading to a newer version of Liferay DXP, as internal libraries like Jackson and Swagger are updated.
Environment
- Liferay 2025.Q1+
- Custom JAX-RS application built with Liferay REST Builder
Resolution
To resolve this, configure the module to import the Jackson annotation package from the DXP runtime instead of bundling it privately. This change forces the module to generate an Import-Package instruction for the Jackson annotations, ensuring it uses the same classes as the DXP runtime and resolving the conflict.
- In the
-apimodule of your custom REST application, open thebnd.bndfile. - Find the
Private-Packageinstruction. - Remove
com.fasterxml.jackson.annotationfrom its list of packages. - Rebuild and redeploy the application modules.
Additional Information
This error is caused by a classloading conflict with the Jackson annotation library. Newer versions of Liferay DXP include an updated version of Jackson that is stricter about how it processes annotations like @JsonIgnore. If the custom REST module's -api artifact bundles its own private copy of the com.fasterxml.jackson.annotation package, the DXP runtime will not recognize the annotations on the generated DTOs. As a result, Jackson detects two setters for the same property, which triggers the exception.