Me too, though I haven't done it in a while. What tomcat version are you using?
Tomcat 5.0.19 on Mac OS X.
exception:I just wrote a Filter that uses a JNDI provided datasource. When I try to access that datasource from the Filter.init(...) I get a
Caused by: javax.naming.NamingException: Cannot create resource instance
Please post the server.xml segment that defines this JNDI resource.
server.xml:
<GlobalNamingResources>
<Resource name="jdbc/test2"
auth="Container"
scope="Shareable"
type="javax.sql.DataSource"
description="JDBC Connection to the DAAP database"/>
<ResourceParams name="jdbc/test2">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
<!-- Validation: http://jakarta.apache.org/commons/dbcp/configuration.html -->
</parameter>
<!-- DBCP database connection settings -->
<parameter>
<name>url</name>
<value>jdbc:postgresql://localhost/test2</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.postgresql.Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>[removed]</value>
</parameter>
<parameter>
<name>password</name>
<value>[removed]</value>
</parameter><!-- DBCP connection pooling options -->
<parameter>
<!-- How long (millis) to wait for a free connection. Deafult: indefinatly, current: 5 seconds -->
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<!-- The query that verifies a connection. -->
<name>validationQuery</name>
<value>SELECT version();</value>
</parameter>
</ResourceParams></GlobalNamingResources>
[...trimmed...]
<DefaultContext>
<ResourceLink name="jdbc/test2" global="jdbc/test2" type="javax.sql.DataSource"/>
</DefaultContext>
web.xml:
<resource-env-ref>
<description>DataSource for the test2 database.</description>
<resource-env-ref-name>jdbc/test2</resource-env-ref-name>
<resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
</resource-env-ref>
I don't think there is a problem with this datasource. I use it both in a DataSourceRealm and it works in my webapp except when I try to access it in my latest Filter.init(...). I can use it fine in Filter.doFilter(...).
I tried reordering my web.xml so that the resource-env-ref came before the problematic filter to no avail.
This wouldn't make a difference: if your web.xml is valid, it's valid. If your web.xml is invalid, you would've gotten an error on startup and not gotten this far.
Yoav Shapira
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
