You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by scottdawson <sc...@gmail.com> on 2013/10/18 23:11:50 UTC

Using a datasource within a blueprint XML

Hello,
I'm trying to use a Postgres datasource in ServiceMix 5 (build from very
recent source). I've installed the Postgres driver:
osgi:install -s wrap:mvn:org.postgresql/postgresql/9.2-1003-jdbc4

Then I deployed the following datasource blueprint which seems to deploy
without error:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
   <bean class="org.postgresql.ds.PGPoolingDataSource" id="datasourceBean">
      <property name="serverName" value="theserver"></property>
      <property name="databaseName" value="mydb"></property>
      <property name="portNumber" value="5432"></property>
      <property name="user" value="usr"></property>
      <property name="password" value="pw"></property>
   </bean>
   <service id="datasourceService" interface="javax.sql.DataSource"
ref="datasourceBean">
      <service-properties>
         <entry key="osgi.jndi.service.name" value="isdms"></entry>
      </service-properties>
   </service>
</blueprint>

Then I've tried to use the datasource in a JDBC component defined within a
blueprint / camelContext / route:
<to uri="jdbc:isdms"/>

or, similarly, a SQL component defined in a blueprint XML:
<to uri="sql:select * from sometable?dataSource=isdms"/>

I get the following error when I deploy the JDBC or SQL component:
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
the registry for: isdms of type: javax.sql.DataSource

How should I specify the datasource in the SQL/JDBC blueprint configuration?

Thank you,
Scott



--
View this message in context: http://servicemix.396122.n5.nabble.com/Using-a-datasource-within-a-blueprint-XML-tp5718094.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Using a datasource within a blueprint XML

Posted by rathisarav <mr...@gmail.com>.
im using the same way as mentioned above but im getting the below error:


org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get
JDBC Connection; nested exception is java.sql.SQLException: Network error
IOException: No buffer space available (maximum connections reached?):
connect

and 

Caused by: java.sql.SQLException: Network error IOException: No buffer space
available (maximum connections reached?): connect

Please do help me out 



--
View this message in context: http://servicemix.396122.n5.nabble.com/Using-a-datasource-within-a-blueprint-XML-tp5718094p5719555.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Using a datasource within a blueprint XML

Posted by scottdawson <sc...@gmail.com>.
Gert,
Yes, I added this to my blueprint XML and now it works correctly:
    <reference id="dataSource" interface="javax.sql.DataSource"
filter="(datasource.name=isdms)"/>

    <bean id="jdbc" class="org.apache.camel.component.jdbc.JdbcComponent">
      <property name="dataSource" ref="dataSource"/>
    </bean>

Thanks,
Scott



--
View this message in context: http://servicemix.396122.n5.nabble.com/Using-a-datasource-within-a-blueprint-XML-tp5718094p5718340.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Using a datasource within a blueprint XML

Posted by Gert Vanthienen <ge...@gmail.com>.
L.S.,


In order to resolve the isdms bean, Camel looks in the Blueprint file
where the Camel route is defined.  You could use a Blueprint
<reference id="isdms" .... /> to grab the DataSource from the OSGi
Service and give it the id you're using to reference it from the Camel
route.


Regards,

Gert Vanthienen


On Fri, Oct 18, 2013 at 11:11 PM, scottdawson <sc...@gmail.com> wrote:
> Hello,
> I'm trying to use a Postgres datasource in ServiceMix 5 (build from very
> recent source). I've installed the Postgres driver:
> osgi:install -s wrap:mvn:org.postgresql/postgresql/9.2-1003-jdbc4
>
> Then I deployed the following datasource blueprint which seems to deploy
> without error:
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>    <bean class="org.postgresql.ds.PGPoolingDataSource" id="datasourceBean">
>       <property name="serverName" value="theserver"></property>
>       <property name="databaseName" value="mydb"></property>
>       <property name="portNumber" value="5432"></property>
>       <property name="user" value="usr"></property>
>       <property name="password" value="pw"></property>
>    </bean>
>    <service id="datasourceService" interface="javax.sql.DataSource"
> ref="datasourceBean">
>       <service-properties>
>          <entry key="osgi.jndi.service.name" value="isdms"></entry>
>       </service-properties>
>    </service>
> </blueprint>
>
> Then I've tried to use the datasource in a JDBC component defined within a
> blueprint / camelContext / route:
> <to uri="jdbc:isdms"/>
>
> or, similarly, a SQL component defined in a blueprint XML:
> <to uri="sql:select * from sometable?dataSource=isdms"/>
>
> I get the following error when I deploy the JDBC or SQL component:
> Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in
> the registry for: isdms of type: javax.sql.DataSource
>
> How should I specify the datasource in the SQL/JDBC blueprint configuration?
>
> Thank you,
> Scott
>
>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Using-a-datasource-within-a-blueprint-XML-tp5718094.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.