Claus Ibsen created CAMEL-25777:
-----------------------------------
Summary: camel-core - the tokenizer EIP does not work in XML and
YAML routes, as only the Java DSL sets the tokenizer name
Key: CAMEL-25777
URL: https://issues.apache.org/jira/browse/CAMEL-25777
Project: Camel
Issue Type: Bug
Components: camel-langchain4j-tokenizer, camel-core
Reporter: Claus Ibsen
Assignee: Claus Ibsen
Fix For: 4.24.0
The tokenizer EIP looks like it cannot work in XML or YAML routes. Only the
Java DSL sets the name of the tokenizer, and the reifier needs that name to
find it.
* {{TokenizerDefinition.tokenizerName}} is {{@XmlTransient}}. Only the
constructor that takes an implementation sets it, and that constructor is what
the Java DSL builder uses.
* The XML parser ({{ModelParser.doParseTokenizerDefinition}}) creates {{new
TokenizerDefinition()}} and calls only {{setTokenizerImplementation(...)}},
which does not set the name. The YAML deserializer does the same.
* {{TokenizerReifier.createProcessor}} resolves {{TOKENIZER_PATH +
definition.tokenizerName()}}, so an XML or YAML route looks up
{{tokenizer/null}}. That should fail with a {{NoSuchServiceException}}.
No test runs the tokenizer EIP from XML or YAML, which is why this was not
seen. I found it by reading the code, while adding XML and YAML tabs to the
tokenizer EIP page (CAMEL-25774). I will add a comment when it is confirmed
with camel run.
A possible fix: {{tokenizerName()}} falls back to
{{tokenizerImplementation.tokenizerName()}} when the name is not set (or
{{setTokenizerImplementation}} sets it), plus an XML and a YAML test in
camel-langchain4j-tokenizer.
A smaller problem in the same model:
{{LangChain4jTokenizerDefinition.modelName}} has {{@XmlAttribute(required =
true)}} while its {{@Metadata}} says {{required = false}}, and the option is
optional. The XSD therefore marks {{modelName}} as required, and a Spring XML
route without it fails XSD validation.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)