On Mon, Apr 25, 2016 at 3:15 PM, Antonin Stefanutti
<anto...@stefanutti.fr> wrote:
> Hi Nicolas,
>
> There is some sort of cyclic dependency in your code from the CDI standpoint.
>
> You have an injection point for @Uri("jms:...") while your have the producer 
> method for the component in the same bean.
>
> I would suggest you either move the producer method in a separate bean, like 
> JmsComponentFactory or declare the producer method static.
>

Yeah that is a good idea to keep those @produces separated from routes
and etc (eg their clients). I guess its a habit of coming up with a
good naming for those factory classes. Do you create 1 class per kind,
or have more in the same class? or a mix?



> Antonin
>
>> On 25 Apr 2016, at 14:46, nicolasduminil 
>> <nicolas.dumi...@simplex-software.fr> wrote:
>>
>> Hi Claus,
>>
>> Many thanks for your suggestion. Now the code looks as follows:
>>
>> public class MyRoutes extends RouteBuilder {
>>  @Inject
>>  @Uri("file:data/inbox?noop=true")
>>  private Endpoint inputEndpoint;
>>
>>  @Inject
>>  @Uri("jms:incommingData")
>>  private Endpoint resultEndpoint;
>>
>>  @Produces
>>  @Named("jms")
>>  public Component jmsComponent()
>>  {
>>    ConnectionFactory connectionFactory = new
>> ActiveMQConnectionFactory("tcp://cac40:61616?create=false");
>>    return JmsComponent.jmsComponentAutoAcknowledge(connectionFactory);
>>  }
>>
>>  @Override
>>  public void configure() {
>>    from(inputEndpoint).to("bean:counterBean").to(resultEndpoint);
>>  }
>> }
>>
>> Running it with camel:run raises the following:
>>
>> [ERROR] Caused by: org.apache.camel.ResolveEndpointFailedException: Failed
>> to resolve endpoint: jms://incommingData due to: Cannot auto create
>> component: jms
>> [ERROR] at
>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:588)
>> [ERROR] at
>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:601)
>> [ERROR] at
>> org.apache.camel.impl.DefaultCamelContext$Proxy$_$$_WeldClientProxy.getEndpoint(Unknown
>> Source)
>> [ERROR] at
>> org.apache.camel.cdi.CdiCamelFactory.endpoint(CdiCamelFactory.java:119)
>> [ERROR] ... 65 more
>>
>> Is there anything else I could try. This code was generated by the
>> maven-camel-jms-cdi archetype.
>>
>> Kind regards,
>>
>> Nicolas DUMINIL
>>
>>
>>
>> --
>> View this message in context: 
>> http://camel.465427.n5.nabble.com/java-lang-IllegalArgumentException-Cannot-add-component-as-its-already-previously-added-jms-tp5781607p5781658.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to