It seems that including a global defined resource using ResourceLink is broken. The link gets bound in JNDI, but retrieving it results in null being returned. This was the case in Tomcat versions 5.5.12 and higher, I believe it is still broken in Tomcat 6. See attached patch for a fix.
Created attachment 19159 [details] Patch which fixes described problem.
-1 for the patch. It's simply that Context.OBJECT_FACTORIES usage is not supported at the moment (same for all the other reference types).
(In reply to comment #2) > -1 for the patch. It's simply that Context.OBJECT_FACTORIES usage is not > supported at the moment (same for all the other reference types). I think it's rather strange to program a bug in getFactoryClassName() because of Context.OBJECT_FACTORIES being unsupported. How about changing it into: public String getFactoryClassName() { String factory = super.getFactoryClassName(); if (factory != null) { return factory; } else { return DEFAULT_FACTORY; } } That would work well in case a custom factory is passed to the constructor, and in case no factory (or null) is specified. On a side note: I'm curious why this issue was never encountered, the documentation contains plenty of documentation about the global resources feature, is it not recommended some way, or is it simply because no one uses it?
Obviously because there's no reason to set Context.OBJECT_FACTORIES, so people don't do it, and they don't run into the unimplemented code.
ResourceLink works for me. If you have a test case (simplest possible jsp / servlet / war + source where appropriate) that demonstrates this issue please re-open this report and attach your test case.
(In reply to comment #5) > ResourceLink works for me. If you have a test case (simplest possible jsp / > servlet / war + source where appropriate) that demonstrates this issue please > re-open this report and attach your test case. I found the problem: since Tomcat 5.5 you can use the Transaction-element instead of the Resource-element, however this is unsupported/broken when used inside GlobalNamingResources-element. Hence I got null as result of the lookup. Should I file a new bug for this problem? The problem goes away when using the old-school Resource. You are right about the patch, it does not solve this problem, I think I changed two things at once (applying the patch and using Resource instead of Transaction).
I suggest you post to the users list to confirm that what you are trying to do is valid and that you have indeed found a bug. If the discussion on the users lists suggest that a bug does exist then please open a new issue.