You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by PeterJNelson <mr...@gmail.com> on 2016/11/02 16:16:52 UTC

Access CamelContext from a plain-old Servlet

I have a web application that uses Camel.  I do not use the camel servlet,
but I do use the Spring ContextLoaderListener to start my CamelContext.

I've tried creating a POJO that implements CamelContextAware, and added that
POJO as a bean in my camel config file.  My servlet then accesses that bean
to get the CamelContext.  Unfortunately, that CamelContext is always null.

Meanwhile, all my routes run just fine. I have beans that operate on
Exchange objects, and they can access CamelContext without issue, but my
POJO always has a null CamelContext.

How do I access an existing CamelContext from a Servlet in the same
environment?



--
View this message in context: http://camel.465427.n5.nabble.com/Access-CamelContext-from-a-plain-old-Servlet-tp5789659.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Access CamelContext from a plain-old Servlet

Posted by Tomohisa Igarashi <tm...@gmail.com>.
working fine for me.
https://github.com/igarashitm/issues/tree/master/camel/camel-servletlistener-hello

On 11/15/2016 03:53 AM, PeterJNelson wrote:
> I did.  "CamelContext" attribute was null.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Access-CamelContext-from-a-plain-old-Servlet-tp5789659p5790115.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Access CamelContext from a plain-old Servlet

Posted by PeterJNelson <mr...@gmail.com>.
I did.  "CamelContext" attribute was null.



--
View this message in context: http://camel.465427.n5.nabble.com/Access-CamelContext-from-a-plain-old-Servlet-tp5789659p5790115.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Access CamelContext from a plain-old Servlet

Posted by Tomohisa Igarashi <tm...@gmail.com>.
Hi,

Did you try this one? It seems to be providing CamelContext as a ServletContext attribute.
http://camel.apache.org/servletlistener-component.html

Thanks,
Tomo

On 11/03/2016 01:16 AM, PeterJNelson wrote:
> I have a web application that uses Camel.  I do not use the camel servlet,
> but I do use the Spring ContextLoaderListener to start my CamelContext.
>
> I've tried creating a POJO that implements CamelContextAware, and added that
> POJO as a bean in my camel config file.  My servlet then accesses that bean
> to get the CamelContext.  Unfortunately, that CamelContext is always null.
>
> Meanwhile, all my routes run just fine. I have beans that operate on
> Exchange objects, and they can access CamelContext without issue, but my
> POJO always has a null CamelContext.
>
> How do I access an existing CamelContext from a Servlet in the same
> environment?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Access-CamelContext-from-a-plain-old-Servlet-tp5789659.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>