You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/07/30 11:41:44 UTC

[GitHub] [camel-k] ogomezdi edited a comment on issue #814: Can camel-k accept camel context definition?

ogomezdi edited a comment on issue #814:
URL: https://github.com/apache/camel-k/issues/814#issuecomment-666288645


   Notice that also in the examples came-k folder there is an [example ](https://github.com/apache/camel-k/blob/master/examples/polyglot/JavaRoute.java) of using @BindToRegistry in conjunction of using multiple files for deploying one integration.
   
   I want also to mention I wan't able to use "packages" for language "java" that will be helpful to have better organization of code supporting logical needed for each integration. I mean, what I'm trying to do is separe the logic from the route itself, so I've created two different java files, one containing only the route, and other implementing the utils (for example), the first one I want to place it in a "package org.something.integrations.route" and the other in a "package org.something.integrations.utils" if I did it in this way and execute this command:
   `kamel run ExampleRoute.java ExampleUtils.java --dev`
   I got this error:
   `[1] Monitoring pod example-route-57664f98f9-6pkkw
   [1] exec java -cp ./resources:/etc/camel/resources:/etc/camel/sources/i-source-000:/etc/camel/sources/i-source-001:dependencies/org.apache.camel.camel-api-3.4.0.jar:dependencies/org.apache.camel.camel-base-3.4.0.jar:dependencies/org.apache.camel.camel-bean-3.4.0.jar:dependencies/org.apache.camel.camel-core-engine-3.4.0.jar:dependencies/org.apache.camel.camel-core-languages-3.4.0.jar:dependencies/org.apache.camel.camel-endpointdsl-3.4.0.jar:dependencies/org.apache.camel.camel-log-3.4.0.jar:dependencies/org.apache.camel.camel-main-3.4.0.jar:dependencies/org.apache.camel.camel-management-api-3.4.0.jar:dependencies/org.apache.camel.camel-support-3.4.0.jar:dependencies/org.apache.camel.camel-timer-3.4.0.jar:dependencies/org.apache.camel.camel-util-3.4.0.jar:dependencies/org.apache.camel.k.camel-k-loader-java-1.4.1.jar:dependencies/org.apache.camel.k.camel-k-runtime-core-1.4.1.jar:dependencies/org.apache.camel.k.camel-k-runtime-main-1.4.1.jar:dependencies/org.apache.logging.log4j.log4j-
 api-2.13.3.jar:dependencies/org.apache.logging.log4j.log4j-core-2.13.3.jar:dependencies/org.apache.logging.log4j.log4j-slf4j-impl-2.13.3.jar:dependencies/org.jooq.joor-0.9.13.jar:dependencies/org.slf4j.slf4j-api-1.7.30.jar org.apache.camel.k.main.Application
   Condition "Ready" is "True" for Integration example-route
   [1] 2020-07-30 11:36:22.187 INFO  [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.ContextConfigurer@503ecb24
   [1] 2020-07-30 11:36:22.192 INFO  [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.RoutesConfigurer@5d12a356
   [1] 2020-07-30 11:36:22.195 INFO  [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.PropertiesConfigurer@4fad9bb2
   [1] 2020-07-30 11:36:22.216 INFO  [main] ApplicationRuntime - Listener org.apache.camel.k.listener.PropertiesConfigurer@4fad9bb2 executed in phase ConfigureProperties
   [1] 2020-07-30 11:36:22.233 INFO  [main] RuntimeSupport - Looking up loader for language: java
   [1] 2020-07-30 11:36:22.237 INFO  [main] RuntimeSupport - Found loader org.apache.camel.k.loader.java.JavaSourceLoader@35f26e72 for language java from service definition
   [1] Exception in thread "main" org.apache.camel.RuntimeCamelException: org.joor.ReflectException: Compilation error: /org/something/integrations/route/ExampleRoute.java:6: error: package org.something.integrations.utils does not exist
   [1] import org.something.integrations.utils.ExampleUtils;
   [1]                                        ^
   [1] 1 error
   [1] 
   [1]     at org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException(RuntimeCamelException.java:52)
   [1]     at org.apache.camel.k.listener.RoutesConfigurer.load(RoutesConfigurer.java:102)
   [1]     at org.apache.camel.k.listener.RoutesConfigurer.load(RoutesConfigurer.java:63)
   [1]     at org.apache.camel.k.listener.RoutesConfigurer.accept(RoutesConfigurer.java:53)
   [1]     at org.apache.camel.k.listener.AbstractPhaseListener.accept(AbstractPhaseListener.java:32)
   [1]     at org.apache.camel.k.main.ApplicationRuntime$MainListenerAdapter.lambda$invokeListeners$0(ApplicationRuntime.java:178)
   [1]     at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
   [1]     at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357)
   [1]     at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
   [1]     at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
   [1]     at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
   [1]     at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
   [1]     at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
   [1]     at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
   [1]     at org.apache.camel.k.main.ApplicationRuntime$MainListenerAdapter.invokeListeners(ApplicationRuntime.java:177)
   [1]     at org.apache.camel.k.main.ApplicationRuntime$MainListenerAdapter.beforeConfigure(ApplicationRuntime.java:142)
   [1]     at org.apache.camel.main.BaseMainSupport.postProcessCamelContext(BaseMainSupport.java:571)
   [1]     at org.apache.camel.main.BaseMainSupport.initCamelContext(BaseMainSupport.java:379)
   [1]     at org.apache.camel.k.main.ApplicationRuntime$MainAdapter.doInit(ApplicationRuntime.java:199)
   [1]     at org.apache.camel.support.service.BaseService.init(BaseService.java:83)
   [1]     at org.apache.camel.main.MainSupport.run(MainSupport.java:56)
   [1]     at org.apache.camel.k.main.ApplicationRuntime.run(ApplicationRuntime.java:72)
   [1]     at org.apache.camel.k.main.Application.main(Application.java:42)
   [1] Caused by: org.joor.ReflectException: Compilation error: /org/something/integrations/route/ExampleRoute.java:6: error: package org.something.integrations.utils does not exist
   [1] import org.something.integrations.utils.ExampleUtils;
   [1]                                        ^
   [1] 1 error
   [1]
   [1]     at org.joor.Compile.compile(Compile.java:102)
   [1]     at org.joor.Reflect.compile(Reflect.java:104)
   [1]     at org.joor.Reflect.compile(Reflect.java:79)
   [1]     at org.apache.camel.k.loader.java.JavaSourceLoader.load(JavaSourceLoader.java:48)
   [1]     at org.apache.camel.k.listener.RoutesConfigurer.load(RoutesConfigurer.java:94)
   [1]     ... 21 more
   Condition "Ready" is "False" for Integration example-route
   `
   
   The content of java files are:
   - ExampleRoute.java
   `// camel-k: language=java name=example-route
   
   package org.something.integrations.route;
   
   import org.apache.camel.builder.RouteBuilder;
   import org.something.integrations.utils.ExampleUtils;
   
   public class ExampleRoute extends RouteBuilder {
   
     @Override
     public void configure() throws Exception {
   
         // Write your routes here, for example:
         from("timer:java?period=5000")
           .routeId("java")
           .setBody(ExampleUtils.doSomething())
           .to("log:info?showAll=true&multiline=true");
     }
   }`
   
   - ExampleUtils.java
   `// camel-k: language=java 
   
   package org.something.integrations.utils;
   
   import org.apache.camel.builder.RouteBuilder;
   
   public class ExampleProcessor extends RouteBuilder {
   
       @Override
       public void configure() throws Exception {
       }
   
       public static String doSomething() {
           return "Hello World!!!";
           };
       }
   
   }`
   
   Done using:
   - Camel K Client 1.1.0
   - minikube version: v1.12.1 over Windows 10 Pro
   - VirtualBox 6.1.12
   


----------------------------------------------------------------
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:
users@infra.apache.org