Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

camel-rest should load automatically for routes using Rest DSL #862

Closed
tadayosi opened this issue Jul 24, 2019 · 3 comments · Fixed by #866
Closed

camel-rest should load automatically for routes using Rest DSL #862

tadayosi opened this issue Jul 24, 2019 · 3 comments · Fixed by #866
Assignees

Comments

@tadayosi
Copy link
Member

Currently examples/RestWithRestlet.java fails unless --dependency=camel-rest is explicitly set:

$ kamel run --name=rest-with-restlet --dependency=camel-restlet examples/RestWithRestlet.java --dev
...
[1] Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route2: Route(route2)[From[rest://get:/hello?consumerComponentName=r... because of Failed to resolve endpoint: rest://get:/hello?consumerComponentName=restlet&routeId=route2 due to: No component found with scheme: rest
[1] 	at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:100)
[1] 	at org.apache.camel.impl.DefaultModel.start(DefaultModel.java:346)
[1] 	at org.apache.camel.impl.DefaultModel.startRoute(DefaultModel.java:320)
[1] 	at org.apache.camel.impl.DefaultModel.startRouteDefinitions(DefaultModel.java:313)
[1] 	at org.apache.camel.impl.DefaultModel.startRouteDefinitions(DefaultModel.java:292)
[1] 	at org.apache.camel.impl.AbstractModelCamelContext.startRouteDefinitions(AbstractModelCamelContext.java:330)
[1] 	at org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:2555)
[1] 	at org.apache.camel.impl.engine.AbstractCamelContext.lambda$doStart$2(AbstractCamelContext.java:2387)
[1] 	at org.apache.camel.impl.engine.AbstractCamelContext.doWithDefinedClassLoader(AbstractCamelContext.java:2404)
[1] 	at org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2385)
[1] 	at org.apache.camel.support.service.ServiceSupport.start(ServiceSupport.java:97)
[1] 	at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2296)
[1] 	at org.apache.camel.main.Main.doStart(Main.java:117)
[1] 	at org.apache.camel.support.service.ServiceSupport.start(ServiceSupport.java:97)
[1] 	at org.apache.camel.main.MainSupport.run(MainSupport.java:196)
[1] 	at org.apache.camel.k.main.ApplicationRuntime.run(ApplicationRuntime.java:70)
[1] 	at org.apache.camel.k.main.Application.main(Application.java:44)
[1] Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: rest://get:/hello?consumerComponentName=restlet&routeId=route2 due to: No component found with scheme: rest
[1] 	at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:779)
[1] 	at org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:55)
[1] 	at org.apache.camel.impl.engine.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114)
[1] 	at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:334)
[1] 	at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:95)
[1] 	... 16 more
@ipolyzos
Copy link
Contributor

Which version of camel-k you are using? I could not reproduce this issue using version 0.3.4

Below is a log of the steps taken to reproduce.

$ kamel version
Camel K Client 0.3.4
$ kamel run --name=rest-with-restlet --dependency=camel-restlet examples/RestWithRestlet.java --dev git:(tags/0.3.4|)
integration "rest-with-restlet" created
integration "rest-with-restlet" in phase Building Context
integration "rest-with-restlet" in phase Deploying
integration "rest-with-restlet" in phase Running
[1] Monitoring pod rest-with-restlet-694996b794-x7jc7[1] Starting the Java application using /opt/run-java/run-java.sh ...
[1] exec java -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:+ExitOnOutOfMemoryError -cp ./resources:/etc/camel/conf:/etc/camel/resources:/etc
/camel/sources/i-source-000:dependencies/com.sun.xml.bind.jaxb-core-2.3.0.jar:dependencies/com.sun.xml.bind.jaxb-impl-2.3.0.jar:dependencies/commons-codec.commons-codec-1.5.jar:dependencies/commons-io.commons-io-2.6.
jar:dependencies/commons-logging.commons-logging-1.1.3.jar:dependencies/javax.servlet.javax.servlet-api-3.1.0.jar:dependencies/net.jcip.jcip-annotations-1.0.jar:dependencies/org.apache.camel.camel-core-2.24.0.jar:dep
endencies/org.apache.camel.camel-http-common-2.24.0.jar:dependencies/org.apache.camel.camel-restlet-2.24.0.jar:dependencies/org.apache.camel.k.camel-k-adapter-camel-2-0.3.3.jar:dependencies/org.apache.camel.k.camel-k
-runtime-core-0.3.3.jar:dependencies/org.apache.camel.k.camel-k-runtime-jvm-0.3.3.jar:dependencies/org.apache.commons.commons-lang3-3.8.1.jar:dependencies/org.apache.httpcomponents.httpclient-4.3.2.jar:dependencies/o
rg.apache.httpcomponents.httpcore-4.3.1.jar:dependencies/org.apache.httpcomponents.httpmime-4.3.jar:dependencies/org.apache.james.apache-mime4j-core-0.7.2.jar:dependencies/org.apache.logging.log4j.log4j-api-2.11.2.ja
r:dependencies/org.apache.logging.log4j.log4j-core-2.11.2.jar:dependencies/org.apache.logging.log4j.log4j-slf4j-impl-2.11.2.jar:dependencies/org.jooq.joor-java-8-0.9.11.jar:dependencies/org.restlet.jee.org.restlet-2.
3.12.jar:dependencies/org.restlet.jee.org.restlet.ext.httpclient-2.3.12.jar:dependencies/org.slf4j.slf4j-api-1.7.25.jar org.apache.camel.k.jvm.Application
[1] OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
[1] 2019-07-24 11:34:35.042 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.ContextConfigurer@654f0d9c
[1] 2019-07-24 11:34:35.047 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.ContextLifecycleConfigurer@50b472aa
[1] 2019-07-24 11:34:35.048 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.RoutesConfigurer@4facf68f
[1] 2019-07-24 11:34:35.049 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.RoutesDumper@15c43bd9
[1] 2019-07-24 11:34:35.064 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.ContextConfigurer@654f0d9c executed in phase ConfigureContext
[1] 2019-07-24 11:34:35.065 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.ContextLifecycleConfigurer@50b472aa executed in phase ConfigureContext
[1] 2019-07-24 11:34:35.093 INFO [main] RoutesConfigurer - Loading routes from: file:/etc/camel/sources/i-source-000/RestWithRestlet.java?language=java
[1] 2019-07-24 11:34:35.575 INFO [main] DefaultTypeConverter - Type converters loaded (core: 195, classpath: 10)
[1] 2019-07-24 11:34:35.587 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesConfigurer@4facf68f executed in phase ConfigureRoutes
[1] 2019-07-24 11:34:35.587 INFO [main] DefaultCamelContext - Apache Camel 2.24.0 (CamelContext: camel-k) is starting
[1] 2019-07-24 11:34:35.588 INFO [main] ManagedManagementStrategy - JMX is enabled
[1] 2019-07-24 11:34:35.739 INFO [main] DefaultCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
[1] 2019-07-24 11:34:35.823 INFO [main] DefaultCamelContext - Route: route1 started and consuming from: direct://hello
[1] Jul 24, 2019 11:34:35 AM org.restlet.engine.connector.NetServerHelper start
[1] INFO: Starting the internal [HTTP/1.1] server on port 8080
[1] 2019-07-24 11:34:35.839 INFO [main] DefaultCamelContext - Route: route2 started and consuming from: restlet://http://0.0.0.0:8080/hello?restletMethods=GET
[1] 2019-07-24 11:34:35.839 INFO [main] DefaultCamelContext - Total 2 routes, of which 2 are started
[1] 2019-07-24 11:34:35.840 INFO [main] DefaultCamelContext - Apache Camel 2.24.0 (CamelContext: camel-k) started in 0.253 seconds
[1] 2019-07-24 11:34:35.840 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesDumper@15c43bd9 executed in phase Started

On another tab creating a proxy to integration.

$ kubectl port-forward rest-with-restlet-694996b794-x7jc7 8080:8080
Forwarding from [::1]:8080 -> 8080
Forwarding from 127.0.0.1:8080 -> 8080

Finally on a third tab testing the service

$ curl localhost:8080/hello
Hello World

@tadayosi
Copy link
Member Author

tadayosi commented Jul 25, 2019

@ipolyzos Yeah, I should've noted that it was an issue with the latest snapshot, which uses Camel 3.0.0-M4 so camel-rest is no longer automatically available:

$ kamel version 
Camel K Client 1.0.0-M1-SNAPSHOT

@pabloxtiyo
Copy link

Im having the same behavior :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants