[
https://issues.apache.org/jira/browse/CAMEL-26964?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-26964 started by Federico Mariani.
------------------------------------------------
> camel-jbang - camel run and camel export still fail on a stored plugin built
> for another Camel version (NoClassDefFoundError)
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26964
> URL: https://issues.apache.org/jira/browse/CAMEL-26964
> Project: Camel
> Issue Type: Bug
> Components: camel-jbang
> Reporter: Federico Mariani
> Assignee: Federico Mariani
> Priority: Minor
> Fix For: 4.24.0
>
>
> CAMEL-26931 made {{camel run}} and {{camel export}} go on without a stored
> plugin that cannot be loaded, with a warning. The catch in
> {{PluginHelper.getActivePlugins}} covers {{RuntimeException}} only, and a
> plugin built for another Camel version fails with a {{LinkageError}} instead.
> For example, a plugin built against Camel 4.23 whose classes refer to
> {{org.apache.camel.dsl.jbang.core.common.Printer}}, which moved to
> {{org.apache.camel.dsl.jbang.run.common.Printer}} in 4.24 (CAMEL-24724).
> {{ObjectHelper.newInstance}} catches {{Exception}} only, so the
> {{NoClassDefFoundError}} of the plugin's constructor lookup escapes and
> {{camel run}} fails:
> {noformat}
> java.lang.NoClassDefFoundError: org/apache/camel/dsl/jbang/core/common/Printer
> at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
> ...
> at
> org.apache.camel.support.ObjectHelper.newInstance(ObjectHelper.java:757)
> at
> org.apache.camel.dsl.jbang.core.common.PluginHelper.downloadPlugin(PluginHelper.java:810)
> at
> org.apache.camel.dsl.jbang.core.common.PluginHelper.resolvePlugin(PluginHelper.java:495)
> at
> org.apache.camel.dsl.jbang.core.common.PluginHelper.getActivePlugins(PluginHelper.java:431)
> at
> org.apache.camel.dsl.jbang.core.commands.CliExportContext.lambda$configure$0(CliExportContext.java:64)
> at
> org.apache.camel.dsl.jbang.run.export.ExportContext.getPlugins(ExportContext.java:86)
> at
> org.apache.camel.dsl.jbang.run.JBangRunner.lambda$plugins$0(JBangRunner.java:128)
> at
> org.apache.camel.dsl.jbang.run.RunPipeline.configure(RunPipeline.java:887)
> ...
> at org.apache.camel.dsl.jbang.core.commands.Run.run(Run.java:834)
> {noformat}
> The same breaks the {{camel_render_route_diagram}} MCP tool, which runs the
> route in process to dump it. The cached path ({{PluginHelper.loadFromCache}})
> already catches {{Exception | LinkageError}}; the factory finder and the
> download paths do not. {{camel plugin add}} has the same gap in
> {{PluginAdd.resolves()}}.
> Expected: {{camel run}} and {{camel export}} warn and go on without such a
> plugin, saying that it does not link with this Camel version; the plugin's
> own command fails with that message instead of a {{NoClassDefFoundError}}.
> _Claude Code on behalf of Croway_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)