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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to