Try adding create=false to the end of the broker URI - i.e 
vm://localhost?create=false

> On Apr 23, 2016, at 5:54 AM, nicolasduminil 
> <[email protected]> wrote:
> 
> Hello,
> 
> I'm trying to run a simple route copying a file content to a JMS destination
> with ActiveMQ. here is the code :
> 
> public class MyRoutes extends RouteBuilder {
> 
>  @Inject
>  @Uri("file:data/inbox?noop=true")
>  private Endpoint inputEndpoint;
> 
>  @Inject
>  @Uri("jms:incommingData")
>  private Endpoint resultEndpoint;
> 
>  @Override
>  public void configure() {
>    ConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("vm://localhost");
>    this.getContext().addComponent("jms",
> JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
>    from(inputEndpoint).to("bean:counterBean").to(resultEndpoint);
>  }
> }
> 
> Running this route raises the following exception:
> 
> [ERROR] Caused by: java.lang.IllegalArgumentException: Cannot add component
> as its already previously added: jms
> [ERROR] at
> org.apache.camel.impl.DefaultCamelContext.addComponent(DefaultCamelContext.java:370)
> [ERROR] at
> fr.simplex_software.tests.camel.copy_file_to_jms_cdi.MyRoutes.configure(MyRoutes.java:27)
> [ERROR] at
> org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:403)
> [ERROR] at
> org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:343)
> [ERROR] at
> org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:326)
> [ERROR] at
> org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:835)
> [ERROR] at
> org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:832)
> [ERROR] at
> org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2867)
> [ERROR] at
> org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:832)
> [ERROR] at
> org.apache.camel.impl.DefaultCamelContext$Proxy$_$$_WeldClientProxy.addRoutes(Unknown
> Source)
> [ERROR] at
> org.apache.camel.cdi.CdiCamelExtension.addRouteToContext(CdiCamelExtension.java:325)
> [ERROR] ... 33 more
> 
> I've tried to comment out the line that adds the JMS component, as the
> exception is saying that the componenet already exists, but then I have the
> following:
> 
> java.lang.IllegalArgumentException: connectionFactory must be specified
>        at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:308)
>        at
> org.apache.camel.component.jms.JmsConfiguration.createConnectionFactory(JmsConfiguration.java:1500)
>        at
> org.apache.camel.component.jms.JmsConfiguration.getConnectionFactory(JmsConfiguration.java:689)
>        at
> org.apache.camel.component.jms.JmsConfiguration.createTemplateConnectionFactory(JmsConfiguration.java:1517)
> 
> So, if I cannot add it because it exists already and I cannot not add it
> because then the connection factory is not defined. I would need to define
> the connection factory without adding the component but I dont find how.
> 
> Many thanks in advance for any help.
> 
> Kind regards,
> 
> Nicolas
> 
> 
> 
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/java-lang-IllegalArgumentException-Cannot-add-component-as-its-already-previously-added-jms-tp5781607.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to