You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Staffan Kvisth <st...@chello.se> on 2003/12/16 15:05:30 UTC

Newbie question about Cocoon DatabaseReader

I have a set of images stored as blobs in a database that I want to retrieve
using a Cocoon DatabaseReader.

I have defined the reader in the sitemap as follows:

 

  <map:readers default="resource">

    <map:reader name="databasereader"
src="org.apache.cocoon.reading.DatabaseReader"
logger="sitemap.reader.databasereader" pool-max="32" pool-min="1"
pool-grow="4">

      <map:parameter name="use-connection" value="mydatabase"/>

    </map:reader>

  </map:readers>

 

I have defined a datasource in the cocoon.xconf that looks like:

 

    <jdbc name="mydatabase" logger="core.datasources.mydatabase">

          <pool-controller min="2" max="5"/>

          <auto-commit>false</auto-commit>

          <dburl>jdbc:mysql://localhost/mydatabase</dburl>

          <user>root</user>

          <password/>

    </jdbc>)

 

Then I want to read the images using the following pipeline:

 

<map:pipeline>

    <map:match pattern="images/*.gif">

      <map:read type="databasereader" src="{1}" mime-type="image/gif">

        <map:parameter name="table" value="images"/>

        <map:parameter name="image" value="image"/>

        <map:parameter name="key" value="id"/>

      </map:read>

    </map:match>

 

    ...

</map:pipeline>

 

However, if I call the pipeline with the URL
http://localhost:8888/mytestweb/images/image1.gif”, I get the following
error message:

 

org.apache.cocoon.ProcessingException: Lookup of reader for role
'databasereader' failed.:
org.apache.avalon.framework.component.ComponentException: readers:
ComponentSelector could not find the component for hint [databasereader]
(key [databasereader])

 

Can someone hint me about what I’m doing wrong?

I don’t think there is a problem with my database connection because I can
access the same data in the database from various XSP’s that I’ve also
written (using esql statements), although the image data blobs then come out
as garbage strings of course. 

 

--

Staffan Kvisth

Tranebergsvägen 41

16745 Bromma

+46-8-264999, +46-70-3439409

staffan.kvisth@chello.se

 


RE: Newbie question about Cocoon DatabaseReader

Posted by Staffan Kvisth <st...@chello.se>.
Problem solved. I’m stupid, I know... Hit me the next time you see me ;-)

I had misconfigured the reader. I should be:

 

  <map:readers default="resource">

    <map:reader name="databasereader"
src="org.apache.cocoon.reading.DatabaseReader"
logger="sitemap.reader.databasereader" pool-max="32" pool-min="1"
pool-grow="4">

     <use-connection>mydatabase</use-connection>

    </map:reader>

  </map:readers>

 

 

-----Original Message-----
From: Staffan Kvisth [mailto:staffan.kvisth@chello.se] 
Sent: den 16 december 2003 15:06
To: users@cocoon.apache.org
Subject: Newbie question about Cocoon DatabaseReader

 

I have a set of images stored as blobs in a database that I want to retrieve
using a Cocoon DatabaseReader.

I have defined the reader in the sitemap as follows:

 

  <map:readers default="resource">

    <map:reader name="databasereader"
src="org.apache.cocoon.reading.DatabaseReader"
logger="sitemap.reader.databasereader" pool-max="32" pool-min="1"
pool-grow="4">

      <map:parameter name="use-connection" value="mydatabase"/>

    </map:reader>

  </map:readers>

 

I have defined a datasource in the cocoon.xconf that looks like:

 

    <jdbc name="mydatabase" logger="core.datasources.mydatabase">

          <pool-controller min="2" max="5"/>

          <auto-commit>false</auto-commit>

          <dburl>jdbc:mysql://localhost/mydatabase</dburl>

          <user>root</user>

          <password/>

    </jdbc>)

 

Then I want to read the images using the following pipeline:

 

<map:pipeline>

    <map:match pattern="images/*.gif">

      <map:read type="databasereader" src="{1}" mime-type="image/gif">

        <map:parameter name="table" value="images"/>

        <map:parameter name="image" value="image"/>

        <map:parameter name="key" value="id"/>

      </map:read>

    </map:match>

 

    ...

</map:pipeline>

 

However, if I call the pipeline with the URL
http://localhost:8888/mytestweb/images/image1.gif”, I get the following
error message:

 

org.apache.cocoon.ProcessingException: Lookup of reader for role
'databasereader' failed.:
org.apache.avalon.framework.component.ComponentException: readers:
ComponentSelector could not find the component for hint [databasereader]
(key [databasereader])

 

Can someone hint me about what I’m doing wrong?

I don’t think there is a problem with my database connection because I can
access the same data in the database from various XSP’s that I’ve also
written (using esql statements), although the image data blobs then come out
as garbage strings of course. 

 

--

Staffan Kvisth

Tranebergsvägen 41

16745 Bromma

+46-8-264999, +46-70-3439409

staffan.kvisth@chello.se