https://issues.apache.org/bugzilla/show_bug.cgi?id=56451
--- Comment #1 from Konstantin Kolinko <knst.koli...@gmail.com> --- 1. Note that this API is not available in Tomcat 8, but you can call > ic.lookup("java:comp/Resources") which will return StandardRoot. 2. Debugging Tomcat 7, the cause for this issue is different from what I expected. > ic.lookup("java:comp/Resources") In Tomcat 7 is an instance of ProxyDirContext. If use the OP way, - The string name is parsed into CompositeName. - There is a series of lookups, each obtaining a org.apache.naming.NamingContext and looking up the name with first component removed. See NamingContext.lookup(Name, boolean resolveLinks:= true) { ... return ((Context) entry.value).lookup(name.getSuffix(1)) } - It goes into ProxyDirContext.lookup(Name) - It does cacheLookup(name.toString()) - The cacheLookup method creates CacheEntry and calls cacheLoad() to fill it. - The cacheLoad method calls dirContext.getAttributes(entry.name). The problem is that 1) name.toString() looks like "some/path/myResource" 2) when you call resource lookup the name will be "/some/path/myResource" with leading "/". This results in - Aliases in BaseDirContext/FileDirContext do not work, as all aliases start with leading "/". - Inconsistency in cache keys in ProxyDirContext. I wonder whether this is better be fixed by consistently adding '/' to the start of the string, or by consistently removing starting '/' from names and aliases. The latter will be more effective (substring is cheaper that string concatenation), and more correct from JNDI API point of view, but it may be easy to miss some use case. It is also possible to say that this is unsupported API and close as wontfix. Note that the following works correctly: ((Context) ic.lookup("java:comp/Resources").lookup("/someAlias/myOtherResource") Note leading "/" in "/someAlias". -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org