DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=28271>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=28271 JNDI resources linked from DefaultContext are not available to Filter.init methods Summary: JNDI resources linked from DefaultContext are not available to Filter.init methods Product: Tomcat 5 Version: 5.0.19 Platform: Macintosh OS/Version: MacOS X Status: NEW Severity: Normal Priority: Other Component: Catalina AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Filters that need to access a DataSource via JNDI fail to initilze when the JNDI resource is linked to the webapp via a ResourceLink in a DefaultContext. The same code works fine when the ResourceLink is in a Context. Also, by the time the Filter.doFilter method a request for a JNDI resource that would fail in the init method will succeed. In case that is unclear, here is a table of where a JNDI look up will work: ResourceLink in | Filter.init | Filter.doFilter DefaultContext | fail | succeed Context | succeed | succeed I've been privately told that: "DefaultContext JNDI references do not get initialized until after plugin init methods are called. It does not appear that the apache developers think this is a problem. The recommendation was to put the resource link into the app's context instead." If that is the case, could the documentation at http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/defaultcontext.html be updated with a comment on this unexpected behavior. It would have saved me half a day's worth of work trying to track this down. If you want test code that demonstrates the problem I'd be happy to upload it. Here is the stack trace from my test code: 2004-04-07 18:11:09 StandardContext[/JNDI]Exception starting filter InitLookup javax.servlet.UnavailableException: Problem looking up resource. at com.example.filter.InitLookup.lookup(InitLookup.java:54) at com.example.filter.InitLookup.init(InitLookup.java:26) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:272) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:355) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:126) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3644) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4276) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126) at org.apache.catalina.core.StandardHost.start(StandardHost.java:832) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:521) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2345) at org.apache.catalina.startup.Catalina.start(Catalina.java:594) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398) Caused by: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.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:198) at com.example.filter.InitLookup.lookup(InitLookup.java:48) ... 19 more --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]