[
https://issues.apache.org/jira/browse/CAMEL-27175?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146764#comment-18146764
]
Claus Ibsen commented on CAMEL-27175:
-------------------------------------
Upstream status:
* Apicurio has an open issue to upgrade json-schema-validator from 1.5.x to
2.0.x: https://github.com/Apicurio/apicurio-registry/issues/10304. That would
*not* fix this one. networknt 2.x and 3.x use the same package and class names
({{com.networknt.schema.Schema}},
{{com.networknt.schema.resource.SchemaLoader}}), and 2.x is built on Jackson 2
while 3.x is built on Jackson 3. A serde on 2.0.x would still clash with the
3.0.9 that Camel uses.
* In the Quarkus 4 migration
(https://github.com/Apicurio/apicurio-registry/pull/11122), Apicurio keeps its
client libraries, the serdes among them, on Jackson 2 and json-schema-validator
1.5.9. A full Jackson 3 move was tried and dropped, because the networknt types
are in the public generics of the JSON Schema serdes.
* I asked on #10304 whether they would consider a Jackson 3 variant of the JSON
Schema serde (networknt 3.x):
https://github.com/Apicurio/apicurio-registry/issues/10304#issuecomment-6981023776
So on the Camel side, the part we can fix is Camel JBang: keep its own
json-schema-validator (used for YAML validation) off the application classpath,
for example by shading it in camel-jbang-core. An application that also uses
camel-json-validator, camel-yaml-dsl-validator, camel-openai or
camel-mcp-server would still have the conflict until Apicurio ships a Jackson 3
serde. Until then the Kafka Kamelets (apache/camel-kamelets#3203) document
{{apicurio}} with {{avro}} only, and the camel-kafka docs could say the same.
_Claude Code on behalf of Claus Ibsen_
> camel-kafka - schemaRegistryVendor apicurio with schemaFormat json fails:
> json-schema-validator 3.x conflicts with the Apicurio serde
> -------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27175
> URL: https://issues.apache.org/jira/browse/CAMEL-27175
> Project: Camel
> Issue Type: Bug
> Components: camel-jbang, camel-kafka
> Reporter: Claus Ibsen
> Priority: Major
>
> With {{schemaRegistryVendor=apicurio}} and {{schemaFormat=json}}
> (CAMEL-27130), sending to Kafka fails on Camel JBang 4.24.0-SNAPSHOT:
> {noformat}
> java.lang.IncompatibleClassChangeError: class
> com.networknt.schema.resource.DefaultSchemaLoader can not implement
> com.networknt.schema.resource.SchemaLoader, because it is not an interface
> (com.networknt.schema.resource.SchemaLoader is in unnamed module of loader
> 'app')
> {noformat}
> h3. Cause
> The Apicurio JSON Schema serde
> ({{io.apicurio:apicurio-registry-jsonschema-serde-kafka}}) is built against
> {{com.networknt:json-schema-validator}} 1.5.x. That is true of the 3.3.3 that
> Camel JBang downloads, and also of 3.3.4, the newest Apicurio release (its
> pom has {{json-schema-validator.version}} 1.5.9).
> Camel moved json-schema-validator to 3.0.9 for Jackson 3 (CAMEL-23172). Camel
> JBang has it on the application classpath, through camel-jbang-core and the
> YAML DSL validator. Both versions use the package {{com.networknt.schema}},
> and in 3.x {{SchemaLoader}} is a class instead of an interface. So the 1.5.x
> classes the serde brings fail to link against the 3.0.9 ones that are already
> loaded.
> The same conflict can happen in any application that has the Apicurio JSON
> Schema serde together with a Camel module using json-schema-validator 3.x:
> camel-json-validator, camel-yaml-dsl-validator, camel-openai or
> camel-mcp-server.
> h3. Reproduce
> Run Apicurio Registry 3.x and Kafka, register a JSON Schema for the subject
> {{orders-value}} (without one the serializer fails earlier with a "not found"
> ProblemDetails), then run with {{camel run route.yaml}}:
> {code:yaml}
> - route:
> from:
> uri: timer:t?repeatCount=1
> steps:
> - setBody:
> constant: '{"id": 1, "item": "camel"}'
> - unmarshal:
> json: {}
> - to:
> uri: kafka:orders
> parameters:
> brokers: localhost:9092
> schemaRegistryVendor: apicurio
> schemaRegistryURL: http://localhost:8080/apis/registry/v3
> schemaFormat: json
> {code}
> {{schemaFormat=avro}} with {{apicurio}} works. {{json}} with {{confluent}}
> works too, because the Confluent serde does not use networknt.
> h3. What is needed
> {{apicurio}} with {{json}} should work in Camel JBang and in Camel
> applications, also next to the Camel modules that use json-schema-validator
> 3.x. Possible ways:
> * Camel JBang keeps its own json-schema-validator (used for YAML validation)
> away from the application classpath, for example by shading it in
> camel-jbang-core.
> * An Apicurio release built on json-schema-validator 2.x/3.x: Camel would
> then use that version and say so in the docs.
> * Until then, the camel-kafka docs and the error message for {{apicurio}}
> with {{json}} point out the conflict.
> Found while adding the schema registry options to the Kafka Kamelets
> (apache/camel-kamelets#3203, which now documents that {{apicurio}} needs
> {{avro}}).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)