Here is the output from java console:

Error starting ApplicationContext. To display the auto-configuration report
re-run your application with 'debug' enabled.
14:52:10.154 [main] INFO
o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext
- Closing org.springframework.boot.context.embedded.AnnotationConfigEm
beddedWebApplicationContext@50f5ad90: startup date [Wed Mar 21 14:52:09 CET
2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEm
beddedWebApplicationContext@2a9377e
14:52:10.154 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Pausing
ProtocolHandler ["http-nio-0.0.0.0-8082"]
14:52:10.154 [main] INFO  o.a.catalina.core.StandardService - Stopping
service Tomcat
14:52:10.154 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Stopping
ProtocolHandler ["http-nio-0.0.0.0-8082"]
14:52:10.170 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Destroying
ProtocolHandler ["http-nio-0.0.0.0-8082"]
14:52:10.185 [main] ERROR o.s.boot.SpringApplication - Application startup
failed
org.apache.camel.spring.boot.CamelSpringBootInitializationException:
org.apache.camel.FailedToStartRouteException: Failed to start route route1
because of duplicate id detected: route2. Please correct ids to be unique
among all your routes.
at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(
RoutesCollector.java:124)
at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(
RoutesCollector.java:41)
at org.springframework.context.event.SimpleApplicationEventMulticas
ter.invokeListener(SimpleApplicationEventMulticaster.java:166)
at org.springframework.context.event.SimpleApplicationEventMulticas
ter.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.context.support.AbstractApplicationContext.
publishEvent(AbstractApplicationContext.java:382)
at org.springframework.context.support.AbstractApplicationContext.
publishEvent(AbstractApplicationContext.java:336)
at org.springframework.context.support.AbstractApplicationContext.
finishRefresh(AbstractApplicationContext.java:877)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.
finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(
AbstractApplicationContext.java:544)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.
refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApp
lication.java:761)
at org.springframework.boot.SpringApplication.refreshContext(Sp
ringApplication.java:371)
at org.springframework.boot.SpringApplication.run(SpringApplica
tion.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplica
tion.java:1186)
at org.springframework.boot.SpringApplication.run(SpringApplica
tion.java:1175)
at org.mycompany.Application.main(Application.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
ssorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
thodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(
AbstractRunMojo.java:506)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.camel.FailedToStartRouteException: Failed to start
route route1 because of duplicate id detected: route2. Please correct ids
to be unique among all your routes.
at org.apache.camel.impl.DefaultCamelContext.startRoute(Default
CamelContext.java:1019)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(
DefaultCamelContext.java:3447)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(Defau
ltCamelContext.java:3178)
at org.apache.camel.impl.DefaultCamelContext.access$000(Default
CamelContext.java:184)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCame
lContext.java:3007)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCame
lContext.java:3003)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(
DefaultCamelContext.java:3026)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCam
elContext.java:3003)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamel
Context.java:2970)
at org.apache.camel.spring.boot.RoutesCollector.maybeStart(Rout
esCollector.java:141)
at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(
RoutesCollector.java:116)
... 21 common frames omitted
14:52:10.185 [main] INFO
o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext
- Closing org.springframework.boot.context.embedded.AnnotationConfigEm
beddedWebApplicationContext@2a9377e: startup date [Wed Mar 21 14:52:01 CET
2018]; root of context hierarchy
14:52:10.185 [main] INFO  o.s.c.s.DefaultLifecycleProcessor - Stopping
beans in phase 0
14:52:10.185 [main] INFO  o.s.b.a.e.jmx.EndpointMBeanExporter -
Unregistering JMX-exposed beans on shutdown
14:52:10.185 [main] INFO  o.s.b.a.e.jmx.EndpointMBeanExporter -
Unregistering JMX-exposed beans
14:52:10.185 [main] INFO  o.s.j.e.a.AnnotationMBeanExporter - Unregistering
JMX-exposed beans on shutdown
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
ssorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
thodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(
AbstractRunMojo.java:506)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.camel.spring.boot.CamelSpringBootInitializationException:
org.apache.camel.FailedToStartRouteException: Failed to start route route1
because of duplicate id detected: route2. Please correct ids to be unique
among all your routes.
at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(
RoutesCollector.java:124)
at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(
RoutesCollector.java:41)
at org.springframework.context.event.SimpleApplicationEventMulticas
ter.invokeListener(SimpleApplicationEventMulticaster.java:166)
at org.springframework.context.event.SimpleApplicationEventMulticas
ter.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.context.support.AbstractApplicationContext.
publishEvent(AbstractApplicationContext.java:382)
at org.springframework.context.support.AbstractApplicationContext.
publishEvent(AbstractApplicationContext.java:336)
at org.springframework.context.support.AbstractApplicationContext.
finishRefresh(AbstractApplicationContext.java:877)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.
finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(
AbstractApplicationContext.java:544)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.
refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApp
lication.java:761)
at org.springframework.boot.SpringApplication.refreshContext(Sp
ringApplication.java:371)
at org.springframework.boot.SpringApplication.run(SpringApplica
tion.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplica
tion.java:1186)
at org.springframework.boot.SpringApplication.run(SpringApplica
tion.java:1175)
at org.mycompany.Application.main(Application.java:32)
... 6 more
Caused by: org.apache.camel.FailedToStartRouteException: Failed to start
route route1 because of duplicate id detected: route2. Please correct ids
to be unique among all your routes.
at org.apache.camel.impl.DefaultCamelContext.startRoute(Default
CamelContext.java:1019)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(
DefaultCamelContext.java:3447)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(Defau
ltCamelContext.java:3178)
at org.apache.camel.impl.DefaultCamelContext.access$000(Default
CamelContext.java:184)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCame
lContext.java:3007)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCame
lContext.java:3003)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(
DefaultCamelContext.java:3026)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCam
elContext.java:3003)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamel
Context.java:2970)
at org.apache.camel.spring.boot.RoutesCollector.maybeStart(Rout
esCollector.java:141)
at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(
RoutesCollector.java:116)
... 21 more
[INFO] ------------------------------------------------------------
------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------
------------
[INFO] Total time: 22.964 s
[INFO] Finished at: 2018-03-21T14:52:10+01:00
[INFO] Final Memory: 68M/796M
[INFO] ------------------------------------------------------------
------------
[ERROR] Failed to execute goal org.springframework.boot:sprin
g-boot-maven-plugin:1.4.1.RELEASE:run (default-cli) on project
camel-ose-springboot-xml: An exception occurred while running. null:
InvocationTargetException: org.apache.camel.FailedToStartRouteException:
Failed to start route route1 because of duplicate id detected: route2.
Please correct ids to be unique among all your routes. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,
please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExec
utionException

I tried to print thread id's to figure out  how many instances of
Routebuilder are actually running, but I don't get it how many are there.
In a Run Configuration I tried to set up 1 thread, where there is a combo
box that offers two options (1 or 2 threads), and it is a default anyway,
but I still get this error.
Furthermore, it really doesn't have anything to do with the second route,
the error appears even if I remove it. As long as there is rest code in my
builder,
I get the error, only if I remove it, the other route starts fine. So, it
must be something related to configuring the rest within the routebuilder
or within camel context.
For example, if I add the following line:

     restConfiguration().component("servlet").enableCORS(true).bindingMode(
RestBindingMode.off).contextPath("/api").apiContextPath("/api-doc");

I somehow introduce another context, or another thread, or another route
instance, or whatever (I don't understand it perfectly yet), and then I
receive this:

Failed to start route route1 because of duplicate id detected: route3.

That is when I have both rest and the second route defined in the
routebuilder at the same time, and if I remove .apiContextPath("/api-doc"),
then again the error becomes:

Failed to start route route1 because of duplicate id detected: route2.

I tried to avoid to explicitly configure Camel context both by instatiating
it as a Java class, or by configuring it through camel-context.xml, but I
don't know how to do it, since I have to add somehow ibm mq component to
it, one way or the other. So if I rewrite things and move all code from
camel-context.xml to a Java class, to instatiate Camel context there, and
add routes to it by using routebuilder, I may end up with the same problem,
which I don't understand. Do I have to establish the route startup order,
or restrict the number of threads, or ensure that each route has unique id,
or what is the problem here? The error handling appears a bit ambiguous to
me, as I am a newbie in this technology.

Reply via email to