You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by LiamO <li...@gmail.com> on 2016/08/08 15:31:01 UTC

Camel cannot find a Karaf registered datasource

Hi, I had a lot of fun and games registering a firebird datasource in Karaf.
Thanks to PAX-JDBC and Christian Scheider's tutorial I was able to manage
this and have the datasource 

karaf@root()> jdbc:ds-list Name | Product | Version | URL | Status
------------------------------------------------------------------------------------------------------------------------
---------- 
unbdev | Firebird 2.58LI | LI-V2.5.3.26778 |
jdbc:firebirdsql:java://lo-******-dev-01/opt/unb/db/*********12-05-2016.fdb
| OK 

I can interrogate the db using the Karaf jdbc commands. Unfortunately when I
try to run a Camel instance containing the following route 

public void configure() throws Exception {
  from("direct:makeFile")
  .to("jdbc:unbdev").split(body()).process(new ResultToReport())
  .to("file:/testx/?charset=utf-8") .to("direct:makeFileComplete"); 
} 

I get an Activator start error with the cause 

Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
route route71 at: >>> To[jdbc:unbdev] <<< in route:
Route(route71)[[From[direct:makeFile]] -> [To[jdbc:unbdev], ... because of
Failed to resolve endpoint: jdbc://unbdev due to: No bean could be found in
the registry for: unbdev of type: javax.sql.DataSource 

Naturally the route works fine in a unit test outside of Karaf using a
simple registry. I'm sorry as it looks like something so simple but I am
just left scratching my head. Oh and I am running on Karaf 4.0.5 and Camel
2.17.2. Thanks in advance. 
Regards, Liam




--
View this message in context: http://karaf.922171.n3.nabble.com/Camel-cannot-find-a-Karaf-registered-datasource-tp4047459.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Camel cannot find a Karaf registered datasource

Posted by LiamO <li...@gmail.com>.
Thanks Christian and Jean-Baptiste. You cleared up some misconceptions I had
about Camel and Karaf. At this point I am trying to avoid Blueprint and
Spring (not knocking them) so I found that using the jndi registry was the
easiest way to make the service visible to my component.
Regards,
Liam



--
View this message in context: http://karaf.922171.n3.nabble.com/Camel-cannot-find-a-Karaf-registered-datasource-tp4047459p4047512.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Camel cannot find a Karaf registered datasource

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

you can take a look on this blog:

http://blog.nanthrax.net/2015/08/talend-esb-query-a-database-directly-in-the-mediation-perspective/

It shows how to use it (it's in Talend studio, but basically the same as 
in Camel).

Regards
JB

On 08/08/2016 05:31 PM, LiamO wrote:
> Hi, I had a lot of fun and games registering a firebird datasource in Karaf.
> Thanks to PAX-JDBC and Christian Scheider's tutorial I was able to manage
> this and have the datasource
>
> karaf@root()> jdbc:ds-list Name | Product | Version | URL | Status
> ------------------------------------------------------------------------------------------------------------------------
> ----------
> unbdev | Firebird 2.58LI | LI-V2.5.3.26778 |
> jdbc:firebirdsql:java://lo-******-dev-01/opt/unb/db/*********12-05-2016.fdb
> | OK
>
> I can interrogate the db using the Karaf jdbc commands. Unfortunately when I
> try to run a Camel instance containing the following route
>
> public void configure() throws Exception {
>   from("direct:makeFile")
>   .to("jdbc:unbdev").split(body()).process(new ResultToReport())
>   .to("file:/testx/?charset=utf-8") .to("direct:makeFileComplete");
> }
>
> I get an Activator start error with the cause
>
> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
> route route71 at: >>> To[jdbc:unbdev] <<< in route:
> Route(route71)[[From[direct:makeFile]] -> [To[jdbc:unbdev], ... because of
> Failed to resolve endpoint: jdbc://unbdev due to: No bean could be found in
> the registry for: unbdev of type: javax.sql.DataSource
>
> Naturally the route works fine in a unit test outside of Karaf using a
> simple registry. I'm sorry as it looks like something so simple but I am
> just left scratching my head. Oh and I am running on Karaf 4.0.5 and Camel
> 2.17.2. Thanks in advance.
> Regards, Liam
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Camel-cannot-find-a-Karaf-registered-datasource-tp4047459.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofr
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Camel cannot find a Karaf registered datasource

Posted by Christian Schneider <ch...@die-schneider.net>.
I think the problem is that camel can not find the DataSource in its 
registry.
If you use blueprint then camel by default bases the registry on 
blueprint beans.
So for jdbc:unbdev it searches for a bean with id="unbdev" and type 
DataSource.
You can provide this bean by defining this reference in blueprint:

<reference id="unbdev" interface="javax.sql.DataSource"/>

This will import the first OSGi service of type DataSource it finds and 
provide it as a named bean in blueprint. If you have more than one
DataSource you will need to add a filter.

See also:
https://docs.google.com/document/d/1oX4RnLWad4b2phlIRluKIZAw9jEakl3Gy61oE1A-AAw/edit

Christian

On 08.08.2016 17:31, LiamO wrote:
> Hi, I had a lot of fun and games registering a firebird datasource in Karaf.
> Thanks to PAX-JDBC and Christian Scheider's tutorial I was able to manage
> this and have the datasource
>
> karaf@root()> jdbc:ds-list Name | Product | Version | URL | Status
> ------------------------------------------------------------------------------------------------------------------------
> ----------
> unbdev | Firebird 2.58LI | LI-V2.5.3.26778 |
> jdbc:firebirdsql:java://lo-******-dev-01/opt/unb/db/*********12-05-2016.fdb
> | OK
>
> I can interrogate the db using the Karaf jdbc commands. Unfortunately when I
> try to run a Camel instance containing the following route
>
> public void configure() throws Exception {
>    from("direct:makeFile")
>    .to("jdbc:unbdev").split(body()).process(new ResultToReport())
>    .to("file:/testx/?charset=utf-8") .to("direct:makeFileComplete");
> }
>
> I get an Activator start error with the cause
>
> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
> route route71 at: >>> To[jdbc:unbdev] <<< in route:
> Route(route71)[[From[direct:makeFile]] -> [To[jdbc:unbdev], ... because of
> Failed to resolve endpoint: jdbc://unbdev due to: No bean could be found in
> the registry for: unbdev of type: javax.sql.DataSource
>
> Naturally the route works fine in a unit test outside of Karaf using a
> simple registry. I'm sorry as it looks like something so simple but I am
> just left scratching my head. Oh and I am running on Karaf 4.0.5 and Camel
> 2.17.2. Thanks in advance.
> Regards, Liam
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Camel-cannot-find-a-Karaf-registered-datasource-tp4047459.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com