camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roy Truelove (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAMEL-9110) Camel not fully ready before needed in another bean's init
Date Thu, 03 Sep 2015 16:51:47 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-9110?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Roy Truelove updated CAMEL-9110:
--------------------------------
    Description: 
(Can reproduce using this repo: https://github.com/roytruelove/camelBug)

I have:

* An interface {{ExternalService}} which I've proxied using {{camel:proxy}}, pointing to {{direct:start}}.
* A class {{UsesExternalServiceDuringInit}} into which the proxy is injected. During its Spring
{{afterPropertiesSet()}} initialization method, the proxy is used.
* A route which defines the {{direct:start}} endpoint.

The full stack trace can be found below, but the core error that I get when starting Spring
is

{code}
No consumers available on endpoint: Endpoint[direct://start]. Exchange[Message: BeanInvocation
public abstract java.lang.String org.apache.camel.example.spring.ExternalService.someMethodOnExternalService()
with null]]
{code}

What it looks like is happening (and feel free to correct!) is:

* Because {{UsesExternalServiceDuringInit}} depends on the {{camel}} bean, {{afterPropertiesSet()}}
is called on {{SpringCamelContext}}, but this does not start the routes.
* {{afterPropertiesSet()}} is called on {{UsesExternalServiceDuringInit}}, expecting its instance
of {{ExternalService}} to be ready to use.
* The routes are not started, so {{direct:start}} is not yet consuming and the init fails.

>From what I see the starting of the routes happens once the spring context is fully initialized,
meaning that any calls to the proxy during spring's init will fail.

BTW I've tried this without a proxy, simply using a ProducerTemplate with the same issue.

I don't yet have an idea for a fix / workaround - will update if I find one.

Full stack trace if needed:

{code}
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:488)
	at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'org.apache.camel.example.spring.UsesExternalServiceDuringInit#0' defined in file [/Users/roytruelove/src/personal/camel-bugfix2/target/classes/META-INF/spring/camel-context.xml]:
Invocation of init method failed; nested exception is java.lang.reflect.UndeclaredThrowableException
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
	at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:217)
	at org.apache.camel.spring.Main.doStart(Main.java:157)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:149)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:353)
	at org.apache.camel.spring.Main.main(Main.java:90)
	... 6 more
Caused by: java.lang.reflect.UndeclaredThrowableException
	at com.sun.proxy.$Proxy45.someMethodOnExternalService(Unknown Source)
	at org.apache.camel.example.spring.UsesExternalServiceDuringInit.afterPropertiesSet(UsesExternalServiceDuringInit.java:11)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
	... 23 more
Caused by: org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers
available on endpoint: Endpoint[direct://start]. Exchange[Message: BeanInvocation public abstract
java.lang.String org.apache.camel.example.spring.ExternalService.someMethodOnExternalService()
with null]]
	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:38)
	at org.apache.camel.component.bean.AbstractCamelInvocationHandler$1.call(AbstractCamelInvocationHandler.java:110)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at org.apache.camel.component.bean.AbstractCamelInvocationHandler.invokeWithBody(AbstractCamelInvocationHandler.java:128)
	at org.apache.camel.component.bean.CamelInvocationHandler.doInvokeProxy(CamelInvocationHandler.java:45)
	at org.apache.camel.component.bean.AbstractCamelInvocationHandler.invoke(AbstractCamelInvocationHandler.java:82)
	... 27 more
{code}




  was:
(Can reproduce using this repo: https://github.com/roytruelove/camelBug)

I have:

* An interface {{ExternalService}} which I've proxied using {{camel:proxy}}, pointing to {{direct:start}}.
* A class {{UsesExternalServiceDuringInit}} into which the proxy is injected. During its Spring
{{afterPropertiesSet()}} initialization method, the proxy is used.
* A route which defines the {{direct:start}} endpoint.

The full stack trace can be found below, but the core error that I get when starting Spring
is

{code}
No consumers available on endpoint: Endpoint[direct://start]. Exchange[Message: BeanInvocation
public abstract java.lang.String org.apache.camel.example.spring.ExternalService.someMethodOnExternalService()
with null]]
{code}

What it looks like is happening (and feel free to correct!) is:

* Because {{UsesExternalServiceDuringInit}} depends on the {{camel}} bean, {{afterPropertiesSet()}}
is called on {{SpringCamelContext}}, but this does not start the routes.
* {{afterPropertiesSet()}} is called on {{UsesExternalServiceDuringInit}}, expecting its instance
of {{ExternalService}} to be ready to use.
* The routes are not started, so {{direct:start}} is not yet consuming and the init fails.

>From what I see the starting of the routes happens once the spring context is fully initialized,
meaning that any calls to the proxy during spring's init will fail.

I don't yet have an idea for a fix / workaround - will update if I find one.

Full stack trace if needed:

{code}
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:488)
	at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'org.apache.camel.example.spring.UsesExternalServiceDuringInit#0' defined in file [/Users/roytruelove/src/personal/camel-bugfix2/target/classes/META-INF/spring/camel-context.xml]:
Invocation of init method failed; nested exception is java.lang.reflect.UndeclaredThrowableException
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
	at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:217)
	at org.apache.camel.spring.Main.doStart(Main.java:157)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:149)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:353)
	at org.apache.camel.spring.Main.main(Main.java:90)
	... 6 more
Caused by: java.lang.reflect.UndeclaredThrowableException
	at com.sun.proxy.$Proxy45.someMethodOnExternalService(Unknown Source)
	at org.apache.camel.example.spring.UsesExternalServiceDuringInit.afterPropertiesSet(UsesExternalServiceDuringInit.java:11)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
	... 23 more
Caused by: org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers
available on endpoint: Endpoint[direct://start]. Exchange[Message: BeanInvocation public abstract
java.lang.String org.apache.camel.example.spring.ExternalService.someMethodOnExternalService()
with null]]
	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:38)
	at org.apache.camel.component.bean.AbstractCamelInvocationHandler$1.call(AbstractCamelInvocationHandler.java:110)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at org.apache.camel.component.bean.AbstractCamelInvocationHandler.invokeWithBody(AbstractCamelInvocationHandler.java:128)
	at org.apache.camel.component.bean.CamelInvocationHandler.doInvokeProxy(CamelInvocationHandler.java:45)
	at org.apache.camel.component.bean.AbstractCamelInvocationHandler.invoke(AbstractCamelInvocationHandler.java:82)
	... 27 more
{code}




        Summary: Camel not fully ready before needed in another bean's init  (was: Camel Proxy
not fully ready before needed in another bean's init)

Made the ticket more generic as this issue is not only for proxies.

> Camel not fully ready before needed in another bean's init
> ----------------------------------------------------------
>
>                 Key: CAMEL-9110
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9110
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.14.1
>         Environment: MacOS
> java version "1.7.0_51"
> Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
> Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
>            Reporter: Roy Truelove
>
> (Can reproduce using this repo: https://github.com/roytruelove/camelBug)
> I have:
> * An interface {{ExternalService}} which I've proxied using {{camel:proxy}}, pointing
to {{direct:start}}.
> * A class {{UsesExternalServiceDuringInit}} into which the proxy is injected. During
its Spring {{afterPropertiesSet()}} initialization method, the proxy is used.
> * A route which defines the {{direct:start}} endpoint.
> The full stack trace can be found below, but the core error that I get when starting
Spring is
> {code}
> No consumers available on endpoint: Endpoint[direct://start]. Exchange[Message: BeanInvocation
public abstract java.lang.String org.apache.camel.example.spring.ExternalService.someMethodOnExternalService()
with null]]
> {code}
> What it looks like is happening (and feel free to correct!) is:
> * Because {{UsesExternalServiceDuringInit}} depends on the {{camel}} bean, {{afterPropertiesSet()}}
is called on {{SpringCamelContext}}, but this does not start the routes.
> * {{afterPropertiesSet()}} is called on {{UsesExternalServiceDuringInit}}, expecting
its instance of {{ExternalService}} to be ready to use.
> * The routes are not started, so {{direct:start}} is not yet consuming and the init fails.
> From what I see the starting of the routes happens once the spring context is fully initialized,
meaning that any calls to the proxy during spring's init will fail.
> BTW I've tried this without a proxy, simply using a ProducerTemplate with the same issue.
> I don't yet have an idea for a fix / workaround - will update if I find one.
> Full stack trace if needed:
> {code}
> java.lang.reflect.InvocationTargetException
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:606)
> 	at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:488)
> 	at java.lang.Thread.run(Thread.java:744)
> Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'org.apache.camel.example.spring.UsesExternalServiceDuringInit#0' defined in file
[/Users/roytruelove/src/personal/camel-bugfix2/target/classes/META-INF/spring/camel-context.xml]:
Invocation of init method failed; nested exception is java.lang.reflect.UndeclaredThrowableException
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
> 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
> 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636)
> 	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
> 	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
> 	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
> 	at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:217)
> 	at org.apache.camel.spring.Main.doStart(Main.java:157)
> 	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> 	at org.apache.camel.main.MainSupport.run(MainSupport.java:149)
> 	at org.apache.camel.main.MainSupport.run(MainSupport.java:353)
> 	at org.apache.camel.spring.Main.main(Main.java:90)
> 	... 6 more
> Caused by: java.lang.reflect.UndeclaredThrowableException
> 	at com.sun.proxy.$Proxy45.someMethodOnExternalService(Unknown Source)
> 	at org.apache.camel.example.spring.UsesExternalServiceDuringInit.afterPropertiesSet(UsesExternalServiceDuringInit.java:11)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
> 	... 23 more
> Caused by: org.apache.camel.component.direct.DirectConsumerNotAvailableException: No
consumers available on endpoint: Endpoint[direct://start]. Exchange[Message: BeanInvocation
public abstract java.lang.String org.apache.camel.example.spring.ExternalService.someMethodOnExternalService()
with null]]
> 	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:38)
> 	at org.apache.camel.component.bean.AbstractCamelInvocationHandler$1.call(AbstractCamelInvocationHandler.java:110)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
> 	at org.apache.camel.component.bean.AbstractCamelInvocationHandler.invokeWithBody(AbstractCamelInvocationHandler.java:128)
> 	at org.apache.camel.component.bean.CamelInvocationHandler.doInvokeProxy(CamelInvocationHandler.java:45)
> 	at org.apache.camel.component.bean.AbstractCamelInvocationHandler.invoke(AbstractCamelInvocationHandler.java:82)
> 	... 27 more
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message