Claus Ibsen created CAMEL-24865:
-----------------------------------
Summary: camel-jbang - camel run --source-dir breaks the Java
language and the datasource auto-configure: a missing classpath resource is
replaced by a file that does not exist
Key: CAMEL-24865
URL: https://issues.apache.org/jira/browse/CAMEL-24865
Project: Camel
Issue Type: Bug
Components: camel-jbang
Reporter: Claus Ibsen
With {{camel run --source-dir=<dir>}}, a resource {{classpath:x}} that is not
on the classpath is replaced by {{file:<dir>/x}} whether that file exists or
not (DependencyDownloaderResourceLoader, the source-dir branch). The Java
language loads {{classpath:camel-joor.properties?optional=true}} at init: under
--source-dir it gets a file resource that does not exist, the optional intent
is lost, and the init fails with "Cannot load resource
classpath:camel-joor.properties" (logged as an ignored WARN on the context
initializing event). The datasource auto-configure script for
{{spring.datasource.*}} is compiled by that language, so an app with a
datasource fails at startup with "Property 'dataSource' is required", while the
same files run fine without --source-dir.
Reproduce: the sql example on an in-memory H2
(spring.datasource.url=jdbc:h2:mem:shop, driverClassName=org.h2.Driver,
camel.jbang.dependencies=com.h2database:h2:2.3.232): {{camel run sql.camel.yaml
application.properties}} creates the table; {{camel run --source-dir=. --dev}}
fails.
Fix: the source-dir branch falls back to the file only when it exists, the way
the route-directory branch added in CAMEL-24852 does; otherwise the original
(not found) answer is returned so ?optional=true keeps working and an error
names the resource as written. Matters now because CAMEL-24861 makes the
camel-jbang-mcp run tool start every project with --source-dir.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)