avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen McConnell <mcconn...@apache.org>
Subject Re: [merlin] merlin + datasources
Date Wed, 19 Nov 2003 18:53:07 GMT


Jim Alateras wrote:

>I was wondering whether anyone can advice me on how to correctly
>configure the datasource component within merlin. This is what I have
>tried but I get an exception when I execute the block.
>
>1. In the block.xml I use the include directive 
>
><container name="pep">
>	:
>	:
>  <include name="jdbc-manager"
>id="cornerstone-datasources:cornerstone-datasources-impl" version="1.0"
>/>
>
></container>
>

OK - so the result of the above is that the container you have defined 
is exposing itself as a DataSourceSelector service.

>
>2. In the config.xml I have the following
>
><targets>
>  <target path="/pep/jdbc-manager/manager">
>    <configuration>
>      <data-sources>
>        <data-source name="maindb"
>class="org.apache.avalon.excalibur.datasource.JdbcDataSource">
>          <pool-controller min="5" max="10" />
>          <driver>org.gjt.mm.mysql.Driver</driver>
>          <dburl>jdbc:mysql:/localhost/test</dburl>
>          <user>mysql</user>
>          <password>mysql</password>
>          <auto-commit>true</auto-commit>
>        </data-source>
>      </data-sources>
>    </configuration>
>  </target>
>   :
>   :
></targets>
>
>3. In one of my other services, I try to use the datasource like this
>
>        DataSourceComponent ds =
>(DataSourceComponent)_dsSelector.select("maindb");
>

First off - your attempting to narrow to a component implementation 
instread of the service it exposes. I would have assumed that you would 
resolve the DataSourceSelector service from the service manager, then 
incoke select on the returned selector.

>
>But when this service executes I get the following error
>
>java.lang.NullPointerException
>

Umm .. this is a worry - you should not be getting a NPE.

Any chance you could throw together a testcase?

Stephen.

-- 

Stephen J. McConnell
mailto:mcconnell@apache.org

|------------------------------------------------|
| Magic by Merlin                                |
| Production by Avalon                           |
|                                                |
| http://avalon.apache.org/merlin                |
| http://dpml.net/                               |
|------------------------------------------------|





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Mime
View raw message