bvahdat opened a new issue #1963: URL: https://github.com/apache/camel-k/issues/1963
Following the steps to reproduce (using `camel-k 1.3.0`) ``` kamel init camel-spring.xml ``` Then change the content of the generated `camel-spring.xml` as following: ``` <?xml version="1.0" encoding="UTF-8"?> <!-- camel-k: language=xml --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <bean id="myBean" class="org.apache.camel.example.MyBean"/> <route id="xml" xmlns="http://camel.apache.org/schema/spring"> <from uri="timer:xml?period=1000" /> <to uri="bean:myBean?method=hello"/> <to uri="log:info" /> </route> </beans> ``` Create a Java file named `MyBean.java` under the subfolder `./org/my/domain` with the content: ``` package org.my.domain; public class MyBean { public String hello() { return "Hi from MyBean!"; } } ``` Now running: ``` kamel run camel-spring.xml --source ./org/my/domain/MyBean.java --dev ``` I get the following error: ``` [1] 2021-01-30 18:26:16,949 ERROR [org.apa.cam.qua.mai.CamelMainRuntime] (main) Failed to start application: org.apache.camel.RuntimeCamelException: java.lang.ClassCastException: class org.my.domain.MyBean cannot be cast to class org.apache.camel.RoutesBuilder (org.my.domain.MyBean is in unnamed module of loader org.joor.Compile$ByteArrayClassLoader @5aceec94; org.apache.camel.RoutesBuilder is in unnamed module of loader 'app') [1] at org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException(RuntimeCamelException.java:51) [1] at org.apache.camel.k.support.SourcesSupport.load(SourcesSupport.java:111) [1] at org.apache.camel.k.support.SourcesSupport.loadSources(SourcesSupport.java:84) [1] at org.apache.camel.k.listener.SourcesConfigurer.accept(SourcesConfigurer.java:73) [1] at org.apache.camel.k.listener.AbstractPhaseListener.accept(AbstractPhaseListener.java:32) [1] at org.apache.camel.k.quarkus.Application$ListenerAdapter.invokeListeners(Application.java:137) [1] at org.apache.camel.k.quarkus.Application$ListenerAdapter.beforeConfigure(Application.java:99) [1] at org.apache.camel.main.BaseMainSupport.postProcessCamelContext(BaseMainSupport.java:469) [1] at org.apache.camel.quarkus.main.CamelMain.initCamelContext(CamelMain.java:97) [1] at org.apache.camel.quarkus.main.CamelMain.doInit(CamelMain.java:67) [1] at org.apache.camel.support.service.BaseService.init(BaseService.java:83) [1] at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:118) [1] at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49) [1] at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45) [1] at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot-173480958.deploy_0(CamelBootstrapProcessor$boot-173480958.zig:101) [1] at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot-173480958.deploy(CamelBootstrapProcessor$boot-173480958.zig:40) [1] at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:534) [1] at io.quarkus.runtime.Application.start(Application.java:90) [1] at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:97) [1] at io.quarkus.runtime.Quarkus.run(Quarkus.java:62) [1] at io.quarkus.runtime.Quarkus.run(Quarkus.java:38) [1] at io.quarkus.runtime.Quarkus.run(Quarkus.java:104) [1] at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29) [1] Caused by: java.lang.ClassCastException: class org.my.domain.MyBean cannot be cast to class org.apache.camel.RoutesBuilder (org.my.domain.MyBean is in unnamed module of loader org.joor.Compile$ByteArrayClassLoader @5aceec94; org.apache.camel.RoutesBuilder is in unnamed module of loader 'app') [1] at org.apache.camel.k.loader.java.JavaSourceLoader.load(JavaSourceLoader.java:51) [1] at org.apache.camel.k.support.SourcesSupport.load(SourcesSupport.java:103) [1] ... 21 more [1] [1] 2021-01-30 18:26:16,974 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.ClassCastException: class org.my.domain.MyBean cannot be cast to class org.apache.camel.RoutesBuilder (org.my.domain.MyBean is in unnamed module of loader org.joor.Compile$ByteArrayClassLoader @5aceec94; org.apache.camel.RoutesBuilder is in unnamed module of loader 'app') [1] at org.apache.camel.k.loader.java.JavaSourceLoader.load(JavaSourceLoader.java:51) [1] at org.apache.camel.k.support.SourcesSupport.load(SourcesSupport.java:103) [1] at org.apache.camel.k.support.SourcesSupport.loadSources(SourcesSupport.java:84) [1] at org.apache.camel.k.listener.SourcesConfigurer.accept(SourcesConfigurer.java:73) [1] at org.apache.camel.k.listener.AbstractPhaseListener.accept(AbstractPhaseListener.java:32) [1] at org.apache.camel.k.quarkus.Application$ListenerAdapter.invokeListeners(Application.java:137) [1] at org.apache.camel.k.quarkus.Application$ListenerAdapter.beforeConfigure(Application.java:99) [1] at org.apache.camel.main.BaseMainSupport.postProcessCamelContext(BaseMainSupport.java:469) [1] at org.apache.camel.quarkus.main.CamelMain.initCamelContext(CamelMain.java:97) [1] at org.apache.camel.quarkus.main.CamelMain.doInit(CamelMain.java:67) [1] at org.apache.camel.support.service.BaseService.init(BaseService.java:83) [1] at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:118) [1] at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49) [1] at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45) [1] at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot-173480958.deploy_0(CamelBootstrapProcessor$boot-173480958.zig:101) [1] at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot-173480958.deploy(CamelBootstrapProcessor$boot-173480958.zig:40) [1] at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:534) [1] at io.quarkus.runtime.Application.start(Application.java:90) [1] at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:97) [1] at io.quarkus.runtime.Quarkus.run(Quarkus.java:62) [1] at io.quarkus.runtime.Quarkus.run(Quarkus.java:38) [1] at io.quarkus.runtime.Quarkus.run(Quarkus.java:104) [1] at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29) [1] ``` So it seems as if `MyBean` Java class gets interpreted as my Camel `RouteBuilder` to be used. I then `kamel reset` and removed the used option `--source ./org/my/domain/MyBean.java` and tried again in the assumption that maybe the CLI will auto-detect my bean Java class. Then this time I didn't get the error above, but Camel did not detect/start my route: ``` [1] 2021-01-30 18:42:49,183 INFO [org.apa.cam.k.Runtime] (main) Apache Camel K Runtime 1.6.0 [1] 2021-01-30 18:42:49,600 INFO [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime [1] 2021-01-30 18:42:49,735 INFO [org.apa.cam.k.lis.SourcesConfigurer] (main) Loading routes from: SourceDefinition{name='camel-spring', language='xml', location='file:/etc/camel/sources/i-source-000/camel-spring.xml', } [1] 2021-01-30 18:42:49,969 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.7.0 (camel-1) is starting [1] 2021-01-30 18:42:49,973 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) StreamCaching is not in use. If using streams then it's recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html [1] 2021-01-30 18:42:49,977 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Total 0 routes, of which 0 are started [1] 2021-01-30 18:42:49,977 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.7.0 (camel-1) started in 8ms [1] 2021-01-30 18:42:49,984 INFO [io.quarkus] (main) camel-k-integration 1.3.0 on JVM (powered by Quarkus 1.10.3.Final) started in 2.078s. [1] 2021-01-30 18:42:49,985 INFO [io.quarkus] (main) Profile prod activated. [1] 2021-01-30 18:42:49,985 INFO [io.quarkus] (main) Installed features: [camel-bean, camel-core, camel-endpointdsl, camel-k-core, camel-k-loader-xml, camel-k-runtime, camel-log, camel-main, camel-support-common, camel-timer, camel-xml-io, cdi] ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org