I posted this to cocoon user list but did not get a helpful answer, so I try again here. Sorry for double posting:

In one of our Generators we want to use Postgres as Datasource. In
web.xml we added the postgres driver this way:

  <init-param>
      <param-name>load-class</param-name>
      <param-value>
        org.postgresql.Driver
      </param-value>
  </init-param>

In cocoon.xconf we added the parameters for the connection:
 <datasources>
    <jdbc name="vrgis">
      <pool-controller max="10" min="5"/>
      <dburl>jdbc:postgresql://192.168.9.2/vrgis</dburl>
      <user>vrgis</user>
      <password>sigrv</password>
    </jdbc>
  </datasources>

In our Generator we implemented the Interface Composable with this method:

public void compose(ComponentManager manager) throws ComponentException {
ComponentSelector selector = (ComponentSelector)
manager.lookup(DataSourceComponent.ROLE+"Selector");
this.datasource = (DataSourceComponent) selector.select("vrgis");
}

Wenn we try to use the datasource in the generate-method we get a
ClassCastException.

--schnipp
Connection conn =  datasource.getConnection();
System.out.println(conn);
((Jdbc3Connection)conn).addDataType("geometry","org.postgis.PGgeometry");
((Jdbc3Connection)conn).addDataType("MultiLineString","org.postgis.MultiLineString");
--schnipp

The exception occurs when we try to cast the Connection. When we build
the connection ourself everything is working fine:

Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://192.168.9.2/vrgis";
Connection conn = DriverManager.getConnection(url, dbuser, dbpass);
((Jdbc3Connection)conn).addDataType("geometry","org.postgis.PGgeometry");
((Jdbc3Connection)conn).addDataType("MultiLineString","org.postgis.MultiLineString");
System.out.println(conn);

In both ways the System.outs give:
org.postgresql.jdbc3.Jdbc3Connection

Do you have any hints, whats happening here? We are using Cocoon 2.1.3
on Suse Linux 8.1. We tested several postgres-driver version, but that
didn't help out here.

Harald




Reply via email to