git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Please correct ids to be unique among all your routes.


Hi,

I'm using Apache Camel 2.20.1 and spring-boot-1.5.9.RELEASE, besides that I
see spring-context-4.3.13.RELEASE.jar and spring-beans-4.3.13.RELEASE.jar
printed in the error stack trace.
I don't get it, is it possible that I may be adding routes two times, once
through an explicit Camel Context and second time through an implicit
default Camel Context?
I import the configuration for the first by adding this import resource
annotation:


@SpringBootApplication
//load regular Spring XML file from the classpath that contains the Camel
XML DSL
@ImportResource({"classpath:spring/camel-context.xml"})

What files exactly do you want me to send you, that are critical to
understand my problem? I'd rather avoid sending the whole project.

Error starting ApplicationContext. To display the auto-configuration report
re-run your application with 'debug' enabled.
2018-03-23 15:50:33.398  INFO 10492 --- [           main]
ationConfigEmbeddedWebApplicationContext : Closing
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@70f5f57d:
startup date [Fri Mar 23 15:50:32 CET 2018]; parent:
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@29ba4338
2018-03-23 15:50:33.414 ERROR 10492 --- [           main]
o.s.boot.SpringApplication               : Application startup failed

org.apache.camel.RuntimeCamelException:
org.apache.camel.FailedToStartRouteException: Failed to start route
rest_getAccounts because of duplicate id detected: rest_getAccounts. Please
correct ids to be unique among all your routes.
at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1831)
~[camel-core-2.20.1.jar:2.20.1]
at
org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136)
~[camel-spring-2.20.1.jar:2.20.1]
at
org.apache.camel.spring.CamelContextFactoryBean.start(CamelContextFactoryBean.java:369)
~[camel-spring-2.20.1.jar:2.20.1]
at
org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:416)
~[camel-spring-2.20.1.jar:2.20.1]
at
org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:94)
~[camel-spring-2.20.1.jar:2.20.1]
at
org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399)
~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at
org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration.createChildManagementContext(EndpointWebMvcAutoConfiguration.java:193)
~[spring-boot-actuator-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at
org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration.afterSingletonsInstantiated(EndpointWebMvcAutoConfiguration.java:156)
~[spring-boot-actuator-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:781)
~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at
hr.rba.digital.poc.accounts.AccountsApplication.main(AccountsApplication.java:14)
[classes/:na]
Caused by: org.apache.camel.FailedToStartRouteException: Failed to start
route rest_getAccounts because of duplicate id detected: rest_getAccounts.
Please correct ids to be unique among all your routes.
at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1137)
~[camel-core-2.20.1.jar:2.20.1]
at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3727)
~[camel-core-2.20.1.jar:2.20.1]
at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3441)
~[camel-core-2.20.1.jar:2.20.1]
at
org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:208)
~[camel-core-2.20.1.jar:2.20.1]
at
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3249)
~[camel-core-2.20.1.jar:2.20.1]
at
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3245)
~[camel-core-2.20.1.jar:2.20.1]
at
org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3268)
~[camel-core-2.20.1.jar:2.20.1]
at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3245)
~[camel-core-2.20.1.jar:2.20.1]
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
~[camel-core-2.20.1.jar:2.20.1]
at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3168)
~[camel-core-2.20.1.jar:2.20.1]
at
org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133)
~[camel-spring-2.20.1.jar:2.20.1]
... 25 common frames omitted

2018-03-23 15:50:33.414  INFO 10492 --- [           main]
ationConfigEmbeddedWebApplicationContext : Closing
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@29ba4338:
startup date [Fri Mar 23 15:50:23 CET 2018]; root of context hierarchy
2018-03-23 15:50:33.414  INFO 10492 --- [           main]
o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans
on shutdown

Best Regards

On Thu, Mar 22, 2018 at 3:07 PM, Claus Ibsen <claus.ibsen@xxxxxxxxx> wrote:

> Hi
>
> What version of Camel and Spring Boot do you use?
> And can you maybe put your sample project on github or something so we
> can take a look there and try it out
>
> On Tue, Mar 20, 2018 at 6:59 PM,  <hrvoje.djurdjevic@xxxxxx> wrote:
> > Hi,
> >
> > if I try to build this code:
> >
> > package org.mycompany;
> >
> > import org.apache.camel.builder.RouteBuilder;
> > import org.apache.camel.model.rest.RestParamType;
> >
> >
> > public class MyFirstRouterBuilder extends RouteBuilder {
> >      @Override
> >     public void configure() throws Exception {
> >         try{
> >         restConfiguration().component("servlet");
> >             rest()
> >             .get("/accounts/{accountId}/transactions").id("r1")
> >                 .param()
> >                     .name("accountId")
> >                     .type(RestParamType.path)
> >                     .dataType("string")
> >                     .required(true)
> >                 .endParam()
> >                 .to("direct:rest1");
> >
> >                 from("direct:rest1")
> >                  .log("${body}");
> >
> >         }catch(Exception e){
> >
> >         }
> >      }
> > }
> >
> > I receive:
> >
> > org.apache.camel.spring.boot.CamelSpringBootInitializationException:
> > org.apache.camel.FailedToStartRouteException: Failed to start route r1
> > because of duplicate id detected: r1. Please correct ids to be unique
> > among all your routes.
> >
> > If I add .routeId("r2") or .id("r2") to the second route, immediately
> > after from("direct:rest1"), nothing changes.
> >
> > If I remove .id("r1") from the rest get operation, I receive:
> >
> > 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.
> >
> > How is this supposed to be written in order to avoid that error?
> > I inject that into camel context like this:
> >
> >     <bean class="org.mycompany.MyFirstRouterBuilder"
> id="myFirstRouter"/>
> >     <camelContext id="camel" useBreadcrumb="false" xmlns="
> > http://camel.apache.org/schema/spring";>
> >         <routeBuilder ref="myFirstRouter"/>
> >     </camelContext>
> > ______________________
> >
> > Napomena:
> > Ova elektronička poruka i njeni prilozi mogu sadržavati povjerljive
> i/ili povlaštene informacije, a namijenjena je isključivo za upotrebu
> naznačenog primatelja. Ako ste ovu poruku primili greškom, molimo Vas da o
> tome bez odlaganja obavijestite pošiljatelja, da uništite izvornu poruku i
> njene priloge i bez odlaganja poruku i njene priloge izbrišete iz Vašeg
> sistema. Neovlaštena uporaba, distribucija, otkrivanje, umnožavanje ili
> izmjena ove poruke je zabranjena. Raiffeisenbank Austria d.d. ne daje niti
> ne prihvaća pravno obvezujuće izjave putem elektroničkih poruka osim
> ukoliko drugačije nije izričito navedeno. Budući da komunikacija internetom
> nije zaštićena, Raiffeisenbank Austria d.d. ne prihvaća odgovornost za
> sadržaj ove poruke, kao ni za eventualnu štetu nastalu zbog zaraženosti ove
> poruke virusom ili drugim štetnim programom, te zbog eventualnih tehničkih
> problema prilikom dostave ove poruke.
> >
> > Disclaimer:
> > This e-mail message and any attachment may contain confidental and/or
> privileged information and is intended for use by the indicated addressee
> only. If you have received this message in error, please notify the sender
> immediately, destroy the original message and any attachment and delete
> this message and any attachment from your system. Unauthorized use,
> distribution, disclosure, reproduction, or alteration of this e-mail
> message is forbidden. Raiffeisenbank Austria d.d. neither makes nor accepts
> legally binding statements via e-mail unless otherwise stated. Considering
> that internet communication is not secured, Raiffeisenbank Austria d.d. is
> not responsible for the content of this message, for potential damage
> occured due to infection of this message with a virus or other malicious
> program, and for potential technical problems during delivery of this
> message.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>