Federico Mariani created CAMEL-27114:
----------------------------------------
Summary: camel-core - Rest DSL: bindingMode json starts without a
JSON data format, and a missing HTTP component or data format is reported
without the artifact to add
Key: CAMEL-27114
URL: https://issues.apache.org/jira/browse/CAMEL-27114
Project: Camel
Issue Type: Bug
Components: rest, camel-core
Reporter: Federico Mariani
With {{bindingMode}} {{json}} or {{json_xml}} and no JSON data format on the
classpath (no camel-jackson3), the route starts, and every request then fails
with {{Cannot bind to json as message body is not json compatible}}, which
blames the body. The xml binding without camel-jaxb fails at startup ({{XML
DataFormat jaxb not found.}}), but does not say which artifact to add.
{code:java}
restConfiguration().component("platform-http").bindingMode(RestBindingMode.json);
// camel-jackson3 not on the classpath
rest("/orders").post().type(Order.class).to("direct:order");
// starts; a POST of {"id":1} with Content-Type application/json fails:
// Cannot bind to json as message body is not json compatible
{code}
With {{bindingMode}} {{auto}} and neither a JSON nor an XML data format,
nothing is bound and nothing is logged.
When no HTTP component is on the classpath, the error is {{Cannot find
RestConsumerFactory in Registry or as a Component to use}} (the same for
{{RestProducerFactory}} and {{RestApiConsumerFactory}}), without the components
the Rest DSL looks for. A {{component}} name that is not found, such as the
name of a servlet, gives {{No bean could be found in the registry for:
MyServlet of type: org.apache.camel.spi.RestConsumerFactory}} and nothing more.
Expected:
* {{json}} and {{json_xml}} fail when the route is created, with {{JSON
DataFormat jackson not found}} and the artifact to add, as {{xml}} does. The
XML message names its artifact too.
* {{auto}} logs a WARN when it finds neither data format.
* The factory-not-found messages list the components the Rest DSL looks for,
each with its artifact (camel-platform-http first), and the option that picks
one. A component name that is not found says which artifact to add, or which
names the option takes.
_Claude Code on behalf of Federico Mariani_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)