You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sandy McArthur <Sa...@McArthur.org> on 2004/04/07 15:57:18 UTC
Filter.init and JNDI resources
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 exception:
Caused by: javax.naming.NamingException: Cannot create resource instance
at
org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceE
nvFactory.java:146)
at
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:
301)
at
org.apache.naming.NamingContext.lookup(NamingContext.java:838)
at
org.apache.naming.NamingContext.lookup(NamingContext.java:185)
at
org.apache.naming.NamingContext.lookup(NamingContext.java:826)
at
org.apache.naming.NamingContext.lookup(NamingContext.java:185)
at
org.apache.naming.NamingContext.lookup(NamingContext.java:826)
at
org.apache.naming.NamingContext.lookup(NamingContext.java:185)
at
org.apache.naming.NamingContext.lookup(NamingContext.java:826)
at
org.apache.naming.NamingContext.lookup(NamingContext.java:198)
at
org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at
net.sf.hibernate.connection.DatasourceConnectionProvider.configure(Datas
ourceConnectionProvider.java:44)
... 23 more
But when I put the same init code in the Filter.doFilter(...) method
such that it only executes once, but delayed until the webapp has been
made available I have no problems.
I skimmed the servlet 2.4 spec and found nothing stating the
availability of JNDI resources at the time a filter is instantiated.
I tried reordering my web.xml so that the resource-env-ref came before
the problematic filter to no avail.
Does this sound like a bug, an ambiguous part of the Servlet spec, or
am I missing something?
Sandy McArthur
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Filter.init and JNDI resources
Posted by Mike Curwen <gb...@gb-im.com>.
I've been successful looking up a JNDI datasource from filter init(). I
use Tomcat 4.1.29 on slackware9.
> -----Original Message-----
> From: Sandy McArthur [mailto:Sandy@McArthur.org]
> Sent: Wednesday, April 07, 2004 8:57 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Filter.init and JNDI resources
>
>
> 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 exception:
>
> Caused by: javax.naming.NamingException: Cannot create
> resource instance
> at
> org.apache.naming.factory.ResourceEnvFactory.getObjectInstance
> (ResourceE
> nvFactory.java:146)
> at
> javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:
> 301)
> at
> org.apache.naming.NamingContext.lookup(NamingContext.java:838)
> at
> org.apache.naming.NamingContext.lookup(NamingContext.java:185)
> at
> org.apache.naming.NamingContext.lookup(NamingContext.java:826)
> at
> org.apache.naming.NamingContext.lookup(NamingContext.java:185)
> at
> org.apache.naming.NamingContext.lookup(NamingContext.java:826)
> at
> org.apache.naming.NamingContext.lookup(NamingContext.java:185)
> at
> org.apache.naming.NamingContext.lookup(NamingContext.java:826)
> at
> org.apache.naming.NamingContext.lookup(NamingContext.java:198)
> at
> org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
> at
> javax.naming.InitialContext.lookup(InitialContext.java:347)
> at
> net.sf.hibernate.connection.DatasourceConnectionProvider.confi
> gure(Datas
> ourceConnectionProvider.java:44)
> ... 23 more
>
> But when I put the same init code in the Filter.doFilter(...) method
> such that it only executes once, but delayed until the webapp
> has been
> made available I have no problems.
>
> I skimmed the servlet 2.4 spec and found nothing stating the
> availability of JNDI resources at the time a filter is instantiated.
>
> I tried reordering my web.xml so that the resource-env-ref
> came before
> the problematic filter to no avail.
>
> Does this sound like a bug, an ambiguous part of the Servlet
> spec, or
> am I missing something?
>
> Sandy McArthur
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org